2015-12-14 150 views
2

我有一个web项目,其中索引文件位于深层文件夹中。如何隐藏真实的index.php路径

可以说我的项目索引是localhost/xxx/a/b/c/index.php,但我想隐藏/a/b/c路径变成localhost/index.php

如何编码.htaccess以及我应该放在哪里?

谢谢。

+0

只是让** C **网站根 –

回答

2

尝试在的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 
+0

如何,如果我没有public_html文件夹? –

+0

您可以在根文件夹中使用它。 – starkeen

+1

更聪明,只是使网络根 –