Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 重写规则超出内部重定向限制_.htaccess_Mod Rewrite_Url Rewriting_Friendly Url - Fatal编程技术网

.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

在我的站点上,我最多可以接受四个参数,因此我在.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]
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]