Apache默认没有findindex.php,通过index.php设置路由规则

服务器上的Apache设置为默认情况下查找index.php,并且适用于普通文件夹。

但是,我有一个.htaccess规则路由所有请求通过我的路由脚本:

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

使用这些.htaccess内容,服务器返回一个404错误。 只有通过指定/index.php才能调用路由脚本。

任何提示,我在做什么错了?

这听起来像你不允许使用.htaccess文件。 你需要一个<Directory>节,其中包含:

 AllowOverride All 

选项All对你的环境可能不是最好的,所以看一下这个文档 ,看看你将在.htaccess允许的覆盖。