Mod重写隐藏文件夹 [英] Mod Rewrite Hide Folder
问题描述
我认为这是一个非常简单的问题.
I think this is a pretty simple question.
你如何通过 apache 重写来隐藏文件夹.
How do you an apache rewrite to hide a folder.
例如:www.website.com/pages/login.php 到 www.website.com/login.php
EX: www.website.com/pages/login.php to www.website.com/login.php
或 www.website.com/pages/home.php 到 www.website.com/home.php
or www.website.com/pages/home.php to www.website.com/home.php
文件夹需要始终隐藏.谢谢
The folder needs to alway be hidden. thanks
推荐答案
我假设您想要的是浏览器请求/home.php 但服务器实际使用位于/pages/home.php 的文件,对?如果是这样,这应该有效:
I assume what you want is for the browser to request /home.php but the server to actually use the file located at /pages/home.php, right? If so, this should work:
确保安装了 apache mod_rewrite 模块.然后,在您的 apache 配置、虚拟主机配置或(不太理想的).htaccess 文件中使用类似的内容:
Make sure the apache mod_rewrite module is installed. Then, use something like this in your apache config, virtual host config, or (less desirable) .htaccess file:
RewriteEngine On
RewriteRule ^/(.*)$ /pages/$1
规则使用正则表达式,因此如果您不确定,您可能需要查看有关该主题的参考资料.阅读手册以获取有关其他指令的更多信息(RewriteCond 可能非常有用) 或规则选项.
The rules use regular expressions, so you may want to look at a reference on that topic if you're unsure. Read the manual for more info on other directives (RewriteCond can be very useful) or rule options.
这篇关于Mod重写隐藏文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!