.htaccess隐藏2个文件夹路径

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

我很难得到关于管理员的第二个声明,我试图隐藏目录的新的和管理部分。新的似乎是隐藏罚款,但管理员不想知道。是新的第一个规则几乎阻止了第二个规则?如果新的或管理员然后隐藏...,可以将两者组合起来?

I am having difficulties getting the second statement working regarding admins, i am trying to hide both new and admin parts of the directory. new seems to be hiding fine however admin doesnt want to know. IS the first rule for new almost blocking the second one? Is it possible to have the two combined so thestatement would read if either new or admins then hide...?

Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+new/([^\s]+) [NC] RewriteRule ^ %1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (?!^new/)^(.*)$ /new/$1 [L,NC] RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+admins/([^\s]+) [NC] RewriteRule ^ %1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (?!^admins/)^(.*)$ /admins/$1 [L,NC]

推荐答案

您的正则表达式中有语法错误。 char ^ 是您不能匹配的行/字符串的开头,或者在捕获组内部使用它。

You have a syntax error in your regex pattern. The char ^ is a start of line/string you can not match it or use it inside of capture groups.

尝试以下规则:

Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / ##1)Redirect /new/foobar to /foobar## RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+new/([^\s]+) [NC] RewriteRule ^ %1 [R=301,L] ##2)Redirect /admins/foobar to /foobar## RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+admins/([^\s]+) [NC] RewriteRule ^ %1 [R=301,L] ##1)internally redirect /foobar to /new/foobar## RewriteCond %{DOCUMENT_ROOT}/new/$1 -f [OR] RewriteCond %{DOCUMENT_ROOT}/new/$1 -d RewriteRule ^(.+)$ /new/$1 [L,NC] ##2)internally redirect /foobar to /admins/foobar## RewriteCond %{DOCUMENT_ROOT}/admins/$1 -f [OR] RewriteCond %{DOCUMENT_ROOT}/admins/$1 -d RewriteRule ^(.+)$ /admins/$1 [L,NC]

更多推荐

.htaccess隐藏2个文件夹路径

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

发布评论

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

>www.elefans.com

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