I need to deny access to the whole site for everyone except some IPs.
Also, I need to permit access to one folder of site for everyone:
Options +FollowSymLinks
Options +Indexes
RewriteEngine on
# Allow access only for devs
RewriteCond %{REMOTE_ADDR} !10.10.10.10 [NC] # First dev id
RewriteCond %{REMOTE_ADDR} !11.11.11.11 [NC] # Second dev id
# Allow direct access to files
RewriteCond %{REQUEST_FILENAME} !-f
# Redirecting guests
RewriteRule (.*) /coming/soon/index.html [R=307]
# But where to place this condition?
RewriteRule ^/?preview/?$ /preview/index.html [NC]
# Other rules for main site structure
# ...
So, I need the whole site loading only for devs. Other users (guests) will see the /coming/soon/ page
And also guests are allowed to see /preview/ page of the site.
How to do this?
If your
/preview/rewrite is suitable for all users and does not depend on subsequent rewrite rules, the simplest way is to put thisRewriteRulefirst with the[L]flag, so that subsequent rewrites will not be applied.Otherwise, exceptions for
RewriteRulemay be specified asRewriteCondmatching with%{REQUEST_URI}:Also note that your suggested rule would rewrite both
/previewand/preview/into/preview/index.html, and the first of these rewrites may break relative links unless a redirect is performed.