2012-03-01 165 views
1

我的网站,所有的文件都在的public_html根所以我的网址是http://foo.com/index.php删除目录

我提出我的所有文件到酒吧目录所以现在的网址是:http://foo.com/bar/index.php不过,我想喜欢重写网址,以便目录栏不会显示在网址中,并且该网站仍显示为http://foo.com/index.php。达到这个目标的最好方法是什么?我有LAMP托管并可以更改htaccess文件。

在此先感谢。

回答

2

把这个代码在你的.htaccess public_html下:

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

RewriteRule ^((?!bar/).*)$ bar/$1 [NC,L] 

然后你就可以访问你的网站,http://foo.com/index.php

+1

雨的感谢。这帮了我很多。 – Dan 2015-08-12 16:26:30

+0

@ BenPaton:这个答案适合你吗? – anubhava 2015-08-12 16:34:11