简体   繁体   English

.htaccess 302重定向,允许所有子文件夹

[英].htaccess 302 Redirect, Allow all subfolders

So I'd like to standardize the process of updating a site: 所以我想标准化更新网站的过程:

1) 302 Redirect all traffic to a subfolder 2) Allow all contents within that subfolder to be viewable (ex, /images, /scripts) 3) IP exception for my IP and others 1)302将所有流量重定向到子文件夹2)允许查看该子文件夹中的所有内容(例如,/ images / scripts)3)我的IP和其他IP的IP异常

The following does not work properly... while it redirects all visitors except 1.3.3.7, the "images" directory within the "coming-soon" folder is blocked. 以下内容无法正常使用...在重定向1.3.3.7以外的所有访问者时,“ coming-soon”文件夹中的“ images”目录被阻止。

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !=1.3.3.7
RewriteCond %{REQUEST_URI} !=/coming-soon/
RewriteRule .* /coming-soon/ [R=302,L]

The condition /coming-soon/ in RewriteCond %{REQUEST_URI} !=/coming-soon/ only matches the URI /coming-soon/ , URIs within that directory, such as /coming-soon/images or /coming-soon/files . 条件/coming-soon/RewriteCond %{REQUEST_URI} !=/coming-soon/只匹配URI /coming-soon/ ,该目录中的URI,诸如/coming-soon/images/coming-soon/files

However, if you change the line to this, it should work, because it then would match any URI that begins with /coming_soon/ : 但是,如果将这一行更改为该行,它应该可以工作,因为它会匹配以/coming_soon/开头的所有URI:

RewriteCond %{REQUEST_URI} !^/coming_soon/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM