I have the following Apache config, which displays a 503 Service Unavailable error to all visitors except for my IP address:
ErrorDocument 503 /503.html
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^127.0.0.1$
RewriteCond %{REQUEST_URI} !^/503.html$
RewriteRule .* - [R=503]
This is so that I can carry out maintenance on my site without errors showing for users. (I'm using my actual IP, not 127.0.0.1
.)
However, to turn this off or on I need to comment/uncomment all the lines, or completely remove it. On my other server running nginx I used a geo clause with a variable (as seen in this question). So I can just change default
from 0
to 1
to turn it on.
Is there a way to do something similar in Apache?