本文介绍了由于可能的配置错误,请求超出了 10 个内部重定向的限制.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

mod_rewrite 规则抛出此错误

mod_rewrite rule throws this error

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

这是我的规则

RewriteEngine On
# Removes index.php
RewriteBase /
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*families-of-schools/start/(.+?)$ /index.php/toolkit/families-of-schools/start?school=$1 [L]
RewriteRule ^(.*)$ /index.php/$1 [QSA,NC,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]

问题发生在

RewriteRule .*families-of-schools/start/(.+?)$ /index.php/toolkit/families-of-schools/start?school=$1 [L]

我读了很多关于一些循环的文章,但我不知道这里可以有什么循环.手指上的人可以解释一下吗?网址是

I read about and lot saying about some loop but I don't see what loop can be here. Can somebody on fingers explain? The url is

/toolkit/families-of-schools/start/ash-green-school-cv7-9ah

推荐答案

我怀疑问题规则就是您指出的规则.重写一次后,假设 index.php 确实存在,由于第二个条件(!-f),它应该不会再次匹配.然而,第二条规则会将 index.php 附加到 url 直到永恒.

I doubt the problem rule is the rule you pointed out. After rewriting it once, assuming that index.php does actually exist, it should not match again because of the second condition (!-f). The second rule however would prepend index.php to the url until eternity.

为了防止将来出现问题,您还应该将重定向规则移至所有其他规则之上.我建议只使用临时重定向,直到您的 .htaccess 中的所有内容都经过测试并按预期工作.永久重定向会被缓存,如果您在某个地方犯了错误,那么您所做的任何更改都将不可见,直到您完成清除缓存的痛苦过程.

To prevent future problems, you should also move your redirect rule above all other rules. I recommend to only use temporary redirects until everything in your .htaccess is tested and works as expected. Permanent redirects are cached, and if you made a mistake somewhere, any changes you make will not be visible until you go through the painful process of clearing the cache.

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]

RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*families-of-schools/start/(.+?)$ /index.php/toolkit/families-of-schools/start?school=$1 [L]

RewriteCond %{REQUEST_URI} !^/index\.php
RewriteRule ^(.*)$ /index.php/$1 [QSA,NC,L]

这篇关于由于可能的配置错误,请求超出了 10 个内部重定向的限制.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 07:55