我的网站所有文件都在public_html根目录中,因此我的网址为http://foo.com/index.php
我已将所有文件移动到条目目录中,所以现在网址为:http://foo.com/bar/index.php
但是我想重写网址,以便目录栏不显示在网址中,网站仍然显示为http://foo.com/index.php
。实现这一目标的最佳方法是什么?我有LAMP托管,可以更改htaccess文件。
提前致谢。
答案 0 :(得分:2)
将此代码放在public_html下的.htaccess中:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^((?!bar/).*)$ bar/$1 [NC,L]
然后,您可以http://foo.com/index.php