从URL htaccess的阿帕奇删除目录阿帕奇、目录、URL、htaccess

2023-09-02 09:38:30 作者:一个人的荒凉

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

I have website where all the files were in the public_html root so my urls were http://foo.com/index.php

我提出我的所有文件到酒吧目录所以现在的网址是: http://foo.com/bar/index.php 不过,我想重写URL,这样的目录栏没有在网址显示,该网站仍然显示为 http://foo.com/index.php 。什么是实现这一目标的最佳途径?我有LAMP的托管和可以改变htaccess的文件。

I have moved all my files into a bar directory so now the url is: http://foo.com/bar/index.php however I would like to rewrite the URLs so that the the directory bar is not shown in the urls and the site still appears as http://foo.com/index.php. What is the best way of achieving this? I have LAMP hosting and can change htaccess files.

在此先感谢。

推荐答案

将这个code在你的.htaccess public_html下:

Put this code in your .htaccess under public_html:

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

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

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