【问题标题】:.htaccess not rewriting the url.htaccess 不重写网址
【发布时间】:2016-10-29 00:38:57
【问题描述】:

我有一个无法重写的网址

我正在尝试使用以下规则将/section45l 重写为/services/incentives/section45l

RewriteRule ^section45l$ /services/incentives/section45l

但它不起作用。

【问题讨论】:

  • 怎么不工作?给出错误?它有什么作用?
  • 返回404错误文档
  • 那么/services/incentives/section45l 不存在。
  • /services/incentives/section45l uri 是否存在?
  • 其实我需要把“/section-45l/”和“/section-45l”改写成services/incentives/section45l

标签: php .htaccess mod-rewrite joomla url-rewriting


【解决方案1】:

你可以使用类似下面的东西:

RewriteRule ^section45l/?$ /services/incentives/section45l [L,NC]

注意pattern中的?,它使前面的char可选,所以规则也会匹配/section45l

【讨论】:

  • 我尝试过同样的想法。我什至是这样写的。还是不行。
  • 不知道您是否知道我的托管服务提供商让我从 v1.5 安装了 Joomla 3.5.1,它基本上覆盖了我现有的文件结构。所以现在我有 6 年的搜索结果在我重建网站后都失败了。这个旧网址是搜索广告系列链接到的内容。
【解决方案2】:

在 .htaccess 中使用重写规则可能不是解决此问题的最简单方法。

我建议使用最新版本的 Joomla 中内置的重定向组件:

  • 启用“系统 - 重定向”插件,“收集 URL”= 已启用
  • 等几天
  • Components -> Redirect 中,通过单击“404 Hits”列标题对结果进行排序,直到最常见的 404 Hits 位于顶部
  • 编辑每个顶部结果,输入适当的重定向地址,启用重定向并保存
  • 完成后,您可以在“System - Redirect”插件中设置“Collect URLs”=Disabled,然后单击Components -> Redirect 中的“Purge Unpublished”按钮以清除您忽略的已收集 URL

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-23
    • 1970-01-01
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多