Maintenance mode...

Discussion in 'Apache' started by willem, Dec 16, 2009.

  1. #1
    Hi all,

    We have a rewrite rule that we use whenever we want to put a site in maintenance :

    RewriteMap availability txt:/etc/httpd/conf/availability.ini

    RewriteCond ${availability:%{HTTP_HOST}|production} !^production$
    RewriteRule !/in_maintenance/.* http%{ENV:HTTP_SUFFIX}://%{HTTP_HOST}/in_maintenance/? [redirect]

    This works as follows:

    1) We add the string "www.example.com maintenance" to availability.ini
    2) The request is "http://www.example.com/whatever"
    3) The RewriteCond checks - in availability.ini - whether the website is in "maintenance" mode (which is the case)
    4) and rewrite the requested URL to the maintenance page.

    Now we have a slightly modified situation where we want to be able to take a part of the website in maintenance. So the main site www.example.com is available but

    www.example.com/subdir is in maintenance.

    We tried the following :

    RewriteMap availability txt:/etc/apache2/availability.ini
    RewriteCond ${availability:%{HTTP_HOST}/%{SCRIPT_FILENAME}|production} !production
    RewriteCond %{SCRIPT_FILENAME} !${availability:%{HTTP_HOST}}
    RewriteRule .* ${availability:%{HTTP_HOST}} [redirect]

    We thought it would work as follows:

    1) We add the string "www.example.com/subdir /in_maintenance/index.html" to availability.ini
    2) The request is "http://www.example.com/subdir".
    3) The first condition checks - in availability.ini - whether the requested part of the website (/subdir) is in maintenance (which is the case).
    4) The second condition checks - in availability.ini - whether the given location (/subdir) is NOT equal to the string /in_maintenance/index.html (which is the case).
    5) The request is rewritten to http://www.example.com/in_maintenance/index.html

    When testing however, the string "${availability:%{HTTP_HOST}}" in the second condition is not translated to "/in_maintenance/index.html" but remains

    "${availability:%{HTTP_HOST}}"

    Any ideas? Any help is appreciated, but an alternative is welcome also.

    Regards,
    Willem.
     
    willem, Dec 16, 2009 IP