【问题标题】:Htaccess to 301 redirect no ending slash to ending slashHtaccess 到 301 将无结束斜杠重定向到结束斜杠
【发布时间】:2013-09-10 09:58:09
【问题描述】:

我有 2 个显示相同信息的域。我希望不以斜线 301 结尾的那个重定向到那个。

http://domain.com/locations/texas

http://domain.com/locations/texas/

当前重写规则:

RewriteRule ^locations/([a-zA-Z0-9_-]+)/?$ search.php?type=location&slug=$1 [L]

【问题讨论】:

    标签: .htaccess redirect mod-rewrite


    【解决方案1】:

    更改您没有的规则并删除 ? 使尾部斜杠成为要求:

    RewriteRule ^locations/([a-zA-Z0-9_-]+)/$ search.php?type=location&slug=$1 [L]
    

    然后添加这个(之前或之后):

    RewriteRule ^locations/([a-zA-Z0-9_-]+)$ /locations/$1/ [L,R=301]
    

    在没有尾部斜杠的情况下进行请求时重定向浏览器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-05
      • 1970-01-01
      • 2010-10-29
      • 1970-01-01
      相关资源
      最近更新 更多