【问题标题】:RewriteRule: match only first occurance of a string. Match /mystring but not /some/path/to/mystringRewriteRule:只匹配第一次出现的字符串。匹配 /mystring 但不匹配 /some/path/to/mystring
【发布时间】: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?

【问题讨论】:

标签: apache .htaccess mod-rewrite


【解决方案1】:

事实上,RewriteRule 是正确的。 WordPress 永久链接存在问题。请参阅上面的评论。

【讨论】: