我有一个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