使用隐藏的.htaccess文件夹中的网址 [英] Hiding folder in URL using .htaccess

查看:162
本文介绍了使用隐藏的.htaccess文件夹中的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要隐藏URL的文件夹。

I need to hide a folder from a url.

一个例子:

如果我输入 www.mysite.com/Jango 我需要你阅读目录: www.mysite.com/users/Jango 但不希望看到 /用户

If I enter www.mysite.com/Jango I need you to read the directory: www.mysite.com/users/Jango but do not want to see /users

我只是想看看这个在地址栏中输入: www.mysite.com/Jango

I just want to see this in the address bar: www.mysite.com/Jango

推荐答案

的.htaccess / 应该做的

RewriteEngine on
RewriteCond %{REQUEST_URI} !^users/
RewriteRule ^(.*)$ users/$1 [L]

这把任何requset不是以用户/ 因为如果它这样做。

This treats any requset not starting with users/ as if it did.

更新:
如果你希望规则适用于仅 /詹 - > /用户/詹,这将是适当的的.htaccess

Update:
If you want the rule to apply for only /Jango --> /users/Jango, this would be an appropriate .htaccess:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^users/Jango
RewriteRule ^Jango/(.*)$ users/Jango/$1 [L]

(将 [L] -flag停止重写afther这个规则,preventing可能的圆圈反应等)

(The [L]-flag stops rewriting afther this rule, preventing possible circle-reactions etc)

这篇关于使用隐藏的.htaccess文件夹中的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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