为什么这个htaccess重写规则失败了?

时间:2013-05-25 18:14:12

标签: .htaccess rewrite

这条规则都是:

RewriteEngine on

RewriteCond %{REQUEST_URI} \.php$
RewriteRule \.php$ /PHPTest/AB/index.php [L]

......而且这一个:

RewriteEngine on

RewriteCond %{REQUEST_URI} \.php.*$
RewriteRule \.php.*$ /PHPTest/AB/index.php [L]

...导致此错误:

500 Internal Server Error

为什么?

1 个答案:

答案 0 :(得分:1)

您的规则正在生成500 Internal Server Error,因为您正在导致无限循环,当Apache用完Max重定向限制时,它会向浏览器返回500个http代码。

如果要修复它,请将代码更改为:

RewriteCond %{REQUEST_URI} !^/PHPTest/AB/index\.php
RewriteRule \.php$ /PHPTest/AB/index.php [L]

高于RewriteCond将阻止在第一次重定向到/PHPTest/AB/index.php

后执行
相关问题