【发布时间】:2016-03-15 17:05:10
【问题描述】:
我在 .htaccess 中有以下 RewriteRule:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^mystringtoreplace/?$ http://www.example.com/some/other/path/mystringtoreplace [L]
意图是将http://www.example.com/mystringtoreplace重定向到http://www.example.com/some/other/path/mystringtoreplace。
我得到的是一个太多的重定向错误“ERR_TOO_MANY_REDIRECTS”。
如何为该问题编写正确的 RewriteRule?
【问题讨论】:
-
还有其他规定吗?
-
@hjpotter92 重写已添加到 WordPress 站点。我发现example.com/some/other/path/mystringtoreplace 的永久链接实际上设置为example.com/mystringtoreplace 所以WordPress 重定向到/mystringtoreplace,我的规则重定向到/some/other/path/mystringtoreplace。这导致了错误 ERR_TOO_MANY_REDIRECTS。
标签: apache .htaccess mod-rewrite