【发布时间】:2017-11-08 11:41:58
【问题描述】:
我正在尝试制作一个 apache(2) RewriteRule,它使用 QUERY_STRING 将用户重定向到友好的可读 URL,但它会导致重定向循环。
我想要实现的是,当用户请求index.php?layout=751&artnr=# URL 时,该请求被重定向到/another/page/#。
在某种程度上,重定向有效,但 Apache 会在用户到达 /another/page 页面后继续重定向用户
重写规则如下所示:
RewriteCond %{REQUEST_URI} ^/index.php
RewriteCond %{QUERY_STRING} ^layout=751&artnr=(.+)$
RewriteRule ^index\.php$ another/page/%1? [R=301,L]
我一直在搜索有关这种情况的很多问题,但没有一个真正有解决我问题的答案,因为这些问题不使用 QUERY_STRING。
我也尝试添加RewriteOptions maxredirects=1 选项,但这也不能解决问题。
任何帮助将不胜感激。
提前致谢。
【问题讨论】:
标签: apache .htaccess redirect mod-rewrite