【问题标题】:How to .htaccess 301 redirect only if the final URL segment is empty仅当最终 URL 段为空时如何 .htaccess 301 重定向
【发布时间】:2013-08-01 06:52:17
【问题描述】:

我正在使用 ExpressionEngine,它在查看特定类别时会生成这样的 URL:

domain.com/index.php/template_group/template/category_URL_indicator/foo_category/

如果访问者从 URL 的最后一段中删除特定类别,我想重定向他们。例如,如果他们将 URL 设为:

domain.com/index.php/template_group/template/category_URL_indicator/

我尝试了 .htaccess 301 重定向,但重定向较短的 URL 也会重定向较长的 URL。也就是说,如果我把它放在 .htaccess 中:

redirect 301 http://www.domain.com/index.php/template_group/template/category_URL_indicator http://www.domain.com

这还将较长的 URL 重定向为 http://www.domain.com/foo_category/ - 这不是必需的...欢迎任何建议 - 谢谢!

大卫。

【问题讨论】:

    标签: .htaccess expressionengine


    【解决方案1】:

    尝试改用重定向匹配以及开始/结束边界:

    redirect 301 ^index.php/template_group/template/category_URL_indicator$ http://www.domain.com
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-21
      • 2015-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-28
      • 2023-03-25
      • 2013-01-27
      相关资源
      最近更新 更多