简体   繁体   中英

.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

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.

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 .

However, if you change the line to this, it should work, because it then would match any URI that begins with /coming_soon/ :

RewriteCond %{REQUEST_URI} !^/coming_soon/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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