使用隐藏的.htaccess文件夹中的网址

编程入门 行业动态 更新时间:2024-10-25 06:33:34
本文介绍了使用隐藏的.htaccess文件夹中的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要隐藏URL的文件夹。

I need to hide a folder from a url.

一个例子:

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

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

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

I just want to see this in the address bar: www.mysite/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文件夹中的网址

本文发布于:2023-10-31 18:38:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546938.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网址   文件   夹中   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!