In-maintenance rewrite rules
am 21.12.2009 11:38:06 von Willem BosHi all,
We have a rewrite rule that we use whenever we want to put a site in
maintenance (included below). It has served us well for a few years
but as we are using more and more Java web-apps we would like to be
able to extend our script with the ability to put a just a part of a
website in maintenance. For example, currently we put a site into
maintenance by adding the following line into a rewrite map:
www.example.com maintenance
GET's are then redirected to /in_maintenance (location is defined in the rule)
What we would like to be able to do is :
www.example.com/java-app /subdir/to/in_maintenance.html
So, any GET's to /java-app gets redirected to /subdir/to/in_maintenance.html
We have tried a few scenario's (included below) but were unable to get
it to work properly. A push in the right direction would be much
appreciated!
IN DETAIL :
- Our current in-maintenance-mode rewrite rules :
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.
- Our most succesfull attempt at a new ruleset :
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}}"
Regards,
Willem.
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org