.htaccess 重写规则超出内部重定向限制
在我的站点上,我最多可以接受四个参数,因此我在.htaccess中添加了以下内容.htaccess 重写规则超出内部重定向限制,.htaccess,mod-rewrite,url-rewriting,friendly-url,.htaccess,Mod Rewrite,Url Rewriting,Friendly Url,在我的站点上,我最多可以接受四个参数,因此我在.htaccess中添加了以下内容 RewriteEngine On RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /index.php?atr=$1&dir=$2&query=$3&lookup=$4 [L] RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?atr=$1&dir=$2&query=$3 [L] Re
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /index.php?atr=$1&dir=$2&query=$3&lookup=$4 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?atr=$1&dir=$2&query=$3 [L]
RewriteRule ^([^/]*)/([^/]*)$ /index.php?atr=$1&dir=$2 [L]
RewriteRule ^([^/]*)$ /index.php?atr=$1 [L]
在我添加第五行只允许一个参数之前,一切都很正常。这将在index.php的所有实例中返回500个错误,错误如下:
Request exceeded the limit of 10 internal redirects
你的第四条规则是:
RewriteRule ^([^/]*)$ /index.php?atr=$1 [L]
这也与重定向/重写的URL匹配。所以,你会得到如下结果:
http://host/index.php?atr=index.php%3Fatr=index.php%3Fatr=index.php%3Fatr=index.php%3Fatr=index.php
这是重定向循环。要解决这个问题,只需使用一个否定匹配index.php本身的模式
第五条规则是什么?@hjpotter92抱歉,我把它弄得有点混乱,我指的是第五条,第四条规则。
RewriteRule ^((?!index\.php)[^/]*)$ /index.php?atr=$1 [L]