Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.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重写规则失败?_.htaccess_Rewrite - Fatal编程技术网

.htaccess 为什么htaccess重写规则失败?

.htaccess 为什么htaccess重写规则失败?,.htaccess,rewrite,.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 E

这两条规则:

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

为什么?

您的规则正在生成
500内部服务器错误
,因为您正在导致无限循环,并且当Apache超出最大重定向限制时,它将向浏览器返回500个http代码

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

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

上面的
RewriteCond
将在第一次重定向到
/PHPTest/AB/index.php后阻止执行。php
您的规则正在生成
500内部服务器错误
,因为您正在导致无限循环,当Apache超出最大重定向限制时,它将返回500个http代码到浏览器

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

RewriteCond %{REQUEST_URI} !^/PHPTest/AB/index\.php
RewriteRule \.php$ /PHPTest/AB/index.php [L]
在第一次重定向到
/PHPTest/AB/index.php后,上述
RewriteCond
将阻止执行