从URL htaccess的阿帕奇删除目录 [英] Remove directory from url htaccess apache

查看:203
本文介绍了从URL htaccess的阿帕奇删除目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站,所有的文件都在的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

这篇关于从URL htaccess的阿帕奇删除目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆