我有以下.htaccess文件,它应该将所有不存在的文件/文件夹重写为index.php . 有人可以建议一种方法来调试为什么这不起作用?当我去一个不存在的文件夹时,我收到一个404未找到的页面 .
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^.*$ ./index.php
当我访问 domain.com/
时,index.php文件显示正常
.htaccess文件与index.php位于同一目录中
3 回答
首先,您必须确保
mod_rewrite
已启用并正常工作,否则您将继续获得500 Internal Server Error
.您只需使用
apache_get_modules()
即可检查 . 例如,如果它打印
mod_rewrite is installed and ready to be used
,那么你可以使用这样的东西,你能试试这段代码吗:
你试过这个吗?
编辑这里发布你可能会有用Tips for debugging .htaccess rewrite rules