首页 文章

尝试删除.php时出现500内部服务器错误

提问于
浏览
-1

我正在运行一个apache web服务器,每当我尝试从.htaccess中的链接末尾删除.php

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

我在网站的每一页上都收到“500内部服务器错误” . 一切都在.htaccess中没有这个片段的情况下工作

1 回答

  • 0

    您收到500服务器内部错误,导致您的htaccess代码无效 .

    RewriteCond %{REQUEST_FILENAME}\.php
    

    如果你想阻止当目标文件的URL被执行时 RewriteRule ,你应该把 !-f

    RewriteCond %{REQUEST_FILENAME} !-f
    

    使用上面的代替

相关问题