How do we add a second IP address that is allowed to see the site in development?
We can just append just second REMOTE_ADDR
like this since the default flag is [AND]
# BEGIN Maintenance
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^11\.111\.111\.11$ #First Address
RewriteCond %{REMOTE_ADDR} !^123\.45\.67\.89$ #Second Address
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ http://example.com/maintenance.html [R=307,L]
</IfModule>
# END Maintenance
The above rules say if the request if not from first ip and not from second ip and the request is not /maintenance.html
redirect them to maintenance page with headers 502. Props to @cybmeta , correct header for server maintenance is 502 and 307 is for temporary redirect.
The processing order for RewriteRule
:
- The Pattern of the RewriteRule ^(.*)$ is checked first.
- If the pattern results true,
- The Condition
!^11\.111\.111\.11$
would be checked.
- If that Condition is true or the OR-Flag was set to Condition
!^123\.45\.67\.89$
,
- The second condition would be checked.
- If this condition is true, too,then three and so on
- At last,the substitution from the
RewriteRule
is applied.
Should this rule go FIRST above any other .htaccess
rules in WordPress?
Yes/No, it depends on the rules you are having, preferably it should be above WordPress .htaccess
generated rules otherwise flag[L]
(last) in WordPress rules stops processing the next rules.
The [L] flag causes mod_rewrite to stop processing the rule set. In
most contexts, this means that if the rule matches, no further rules
will be processed. This corresponds to the last command in Perl, or
the break command in C. Use this flag to indicate that the current
rule should be applied immediately without considering further rules.
In your case it works either you place it at the top or at the bottom.(not tested)