【发布时间】:2016-06-26 12:23:07
【问题描述】:
谁能告诉我为什么以下内容会明显更改浏览器中的 URL,而不是静默重定向?重定向有效,但很明显。
示例网址: http://domain.com/_test/sportswire/uk/football/huddersfield
...显示查询字符串参数的可见重定向。
RewriteEngine on
RewriteBase /_test/sportswire
#favour naked domain over www
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,NE,L]
#disallow trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
###THIS RULE### channel pages - territory/sport/channel/[res type?]
RewriteRule ^(\w+)\/(\w+)\/(\w+)(?:\/(\w+))?$ channel.php?territory=$1&sport=$2&team=$3&res_type=$4 [L,NC,R=301]
#channel pages - with item (if from external referrer) - territory/sport/channel/res_type/"item"/item_id/pretty
RewriteRule ^(\w+)\/(\w+)\/(\w+)\/(\w+)\/story\/\w{11}\/[^\/]+$ channel.php?territory=$1&sport=$2&team=$3&res_type=$4&item=$5 [L,NC,R=301]
我尝试过/阅读过的内容:
- 删除 R 标志(不高兴;而且我还有其他带有 R 标志的 .htaccess 文件会静默重定向)
- 添加/删除重写基础(完成;也尝试了绝对基础)
- 不要使用绝对 URL(我不是)
我相当确信地球上没有什么比 mod-rewrite 更令人困惑的了。
【问题讨论】:
-
致反对者/接近者:1)问题表明研究工作; 2) 问题清楚地表明了期望的行为是什么——无论是在问题标题还是在它的开头段落中。
-
您是否尝试清除浏览器的缓存?对不起,不是我的 dv
-
@starkeen - 是的,不快乐。
-
从最后两条规则中删除
,R=301并清除浏览器缓存 -
永远不要用
R=301测试!
标签: php .htaccess redirect mod-rewrite