如何隐藏真正的index.php的路径


How to hide path to real index.php

我有一个web项目,其中索引文件位于深层文件夹中。

假设我的项目索引在localhost/xxx/a/b/c/index.php上,但我想将/a/b/c路径隐藏为localhost/index.php

如何对.htaccess进行编码,应该将其放在哪里?

谢谢。

在public_html/.htaccess 中尝试以下操作

RewriteEngine on
#if the request is not for and existent file
RewriteCond %{REQUEST_FILENAME} !-f
#and the request is not for and existent directory
RewriteCond %{REQUEST_FILENAME} !-d
#then rewrite it to /a/b/c/request
RewriteRule ^(?:xxx/)?(.*)$ /xxx/a/b/c/$1 [NC,L]

这将在内部重定向

example.com/file.php

example.com/a/b/c/file.php