0
votes

I've spent many hours with testing different solutions and googling but not succeeeded yet. I'm using VirtualHost with one site for my web site (/var/site1/www/html/) and another for managing maintenance pages or ErrorDocument (/var/msite2/www/html).
My final goal is to allow some IPs to access the site1 during maintenance phase. For denied IPs, I want them to be redirected to a maintenance page responding to the Error 503.
IPs filtering is working. My problem is about redirection.
In the site1 configuratipon file, in the VirtualHost, if I set ErrorDocument 503 "Bad luck !!!", the text is dispalyed on thedenied IP browser.
When I try to set ErrorDocument 503 /var/msite1/www/html/Error503.html, I've got the default 503 text message plus one telling that the system is unable to find the Error503.html.
Does anyone has a real procedure for that ?

1

1 Answers

0
votes

Finally, I reset my mind and found a solution to my problem using environmnet variable, rewriterule ...

# Define Environment Variables
SetEnvif Request_URI ".*" ENVIRONMENT=MAINTENANCE
# Directory for site content
<Directory "/var/site1/www/html">
 AllowOverride All
 Require all granted
 ...
</Directory>
<Directory "/var/msite2/www/html">
 AllowOverride All
 Require all granted
</Directory>
# Maintenance redirection
UseCanonicalName On
RewriteEngine On
RewriteMap exceptions /var/msite2/exceptions.map
RewriteCond %{ENV:ENVIRONMENT} =MAINTENANCE
RewriteCond ${exceptions:%{REMOTE_ADDR}} !=OK
RewriteRule ^/(.*)$ /var/msite2/www/html/$1

It works fine now.