重写 - 重定向所有没有 index.php

Rewrite - Redirecting all without index.php

我的根文件夹中有一个 index.php 空白文件和 Loader.php 个文件,并且有以下代码:

RewriteEngine On
RewriteBase /
RewriteRule . Loader.php [L]

当我删除 index.php 文件(它什么都没有)时,重写不起作用,Apache 返回一个 "Index of"。

如何删除 "index.php" 并保持 Rewrite 正常工作?

尝试将规则的模式从 . 更改为 ^. 表示请求中必须有 至少一个 字符。如果您尝试加载 /(这是一个空白请求),. 模式将不会匹配它。然后,因为您有一个索引文件,它会被映射并且索引文件会通过规则。第二次大约 . 匹配,因为请求中有字符。

RewriteRule ^ Loader.php [L]