我需要能够将目录中的所有 URL 重定向到目录中的 index.php 文件。与我找到的所有其他答案不同,这包括现有目录和现有文件。我正在使用带有 .htaccess 文件的 Apache 来完成此操作。到目前为止,我的 .htaccess 文件如下:
<IfModule mod_rewrite.c>
重写引擎开启
RewriteRule /sub/directory/index\.php - [L]
重写规则 - /sub/directory/index\.php
</IfModule>
但出于某种原因,它不会将任何内容重定向到 index.php。我也试过:
<IfModule mod_rewrite.c>
重写引擎开启
RewriteRule /sub/directory/index\.php - [L]
重写规则 ^.*$ /sub/directory/index\.php
</IfModule>
但这给了我一个不可避免的“500 错误”。我究竟做错了什么?如何简单地将所有内容重定向到 index.php?
holdtom
四季花海
眼眸繁星