Hello everyone,
on wednesday I had the task to upload a major update to one of our companies projects.
My first idea was to disable the system by adding something like the below to the 'index.php' files:
include('include/template/fricking_maintenance.html');
die();
Not such a good idea if you have to test the stuff, because no one, including yourself can access the stuff.
So ... what now? After a short break I got the simple, but stunnig idea. ;-)
Custom HTTP header + modified (in my case, already existing) .htaccess => Everyone, except yourself, get a the 'maintenance mode' message. ;-)
1: # .htaccess
2: RewriteCond %{HTTP:maintenance} !^1$
3: RewriteRule ^(.*)$ maintenance.html
This rule will force everyone, who has NOT a custom http header named 'maintenance' with the value '1', to the 'maintenance.html'. Which literally means everyone, except yourself, get a fancy 'maintenance mode' message thingy while you can view your page as usual and test all your changes. And if an error occurs, no one will see it and you can proceed fixing it.
The very best on that solution is, if you have a complex set of RewriteConds and RewriteRules, then you can still use them if you have the matching HTTP header set and that lines are at the very beginning of your .htaccess . Stunning! :-D
Edit:
To clarify an important thing, you can also use a RewriteCond which is matching your current IP Address. But if your webserver is behind a (complex) Load Balancing solution, the webserver will ALWAYS get the IP Address of the Load Balancer and not yours. Therefore the solution with the HTTP header is a good deal, because it will work in the most cases!
References:
Apache Module: mod_rewrite - RewriteCond
Modify Header, a cool Firefox extension
No comments:
Post a Comment