Url 重写 => 内部服务器错误

Url Rewrite => Internal Server Error

每次在我的 .htaccess 文件中实现 mod-重写代码时,我都会收到内部服务器错误:

RewriteEngine On 
RewriteRule ^([^/]*)\.php$ /index.php?site= [L]

我正在尝试转换:

www.mydomain.com/index.php?site=mysite

www.mydomain.com/mysite.php

错误:

Internal Server Error

非常感谢任何帮助,谢谢

您的规则导致无限循环,因为它重写了所有以 .php 结尾的请求。这也包括 index.php 所以它最终一次又一次地将它重写为 index.php 等等..

只需在您的规则中添加一个排除它的条件。

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/index\.php [NC]
RewriteRule ^([^/]*)\.php$ /index.php?site= [L]