.htaccess文件 - 删除.php扩展名"服务器错误"

时间:2015-11-19 09:29:19

标签: php .htaccess xampp

我刚刚创建了一个 .htaccess 文件,我在Xampp中使用该文件,该文件位于 Z://xampp/htdocs/.htaccess 中我已经添加了代码:

RewriteEngine on
RewriteCond % {REQUEST_FILENAME} !-f
RewriteCond % {REQUEST_FILENAME} !-d
RewriteRule ^ (.*)$1.php [L,QSA]

但是当我加载任何页面时,我收到错误:

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.

我之前见过其他人遇到此错误并尝试过其他人的修复,但没有任何对我有用,当我停止收到错误时,它不会删除.php扩展名。

有谁知道这是什么问题?

1 个答案:

答案 0 :(得分:2)

试试这个

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

以及在Apache httpd.conf中检查重写是否在