Apache mod_rewrite无限循环,无法修复它

时间:2014-10-19 21:17:18

标签: apache .htaccess mod-rewrite

我的htaccess:

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([^/.]+)/([^/.]+)(.*) /Application/?path=$1/$2$3 [L,QSA]
RewriteRule ^$ /Application/?path=ACFrontPage/getMainPage [L,QSA]
RewriteRule (.*) /Application/index.php?path=$1 [L,QSA]

此行导致无限重定向:

RewriteRule (.*) /Application/index.php?path=$1 [L,QSA]

但我需要先前的规则不匹配,将所有内容重定向到index.php文件。 我该怎么办?

从日志中执行此操作:

split uri=/Application/?path=Application/ -> uri=/Application/, args=path=Application/&path=Application/&path=Application/&path=Application/&path=Application/&path=Application/&path=Application/&path=Application/&path=Application/&path=Application/

========================

@anubhava

我尝试了你建议的答案,它适用于除基域之外的所有东西,即: http://example.com/

1 个答案:

答案 0 :(得分:1)

RewriteCond仅适用于下一个RewriteRule。调整规则以避免重写所有现有文件或目录:

RewriteEngine On

RewriteRule ^$ /Application/?path=ACFrontPage/getMainPage [L]

# skip rewrite for all files/directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^([^/.]+)/([^/.]+)(.*)$ /Application/?path=$1/$2$3 [L,QSA]

RewriteRule ^(.+)$ /Application/index.php?path=$1 [L,QSA]