Hello, I have a website based on php/apache with access to .htaccess files. I want to turn off the website completely, for instance a user visiting any page would see a default message saying "we are upgrading this page, please come back tomorrow" (i.e. content of /site_down.php). However, this will need to be done in order to upgrade some parts of the website and test it's functionality so I will need to have access to it. At the moment, whenever site is down for some reason I un-comment one line in /.htaccess and all traffic is redirected to /site_down.php. But I dont have access to it either What would be the easiest solution to make it work so only I have access to it? Hmm, I could probably do a condition in .htaccess saying: if DNS = 'dns.provider.com' then allow else deny (what would be the correct syntax?) Or is it better to do it in php? Can someone advise please?
You can use allow and deny statements. Allow from YOUR_IP Deny from all Note, that might not be the full syntax, it's just a demo. Then, you can do something like: ErrorDocument 403 "Sorry, we're upgrading Code (markup): There is no closing " mark. They will be given the Sorry, we're upgrading message, rather than "403 Forbidden" Jay
this is not possible with 1000+ files, whole structure of directories and PHP paths in scripts.... anyway, will play around with it. ta.
You can use mod_rewrite for this. For example: RewriteEngine On RewriteBase / RewriteCond %{REMOTE_ADDR} !^10\.100\.0\.55$ RewriteCond %{REMOTE_URI} !^upgrading\.html$ RewriteRule ^(.*)$ /upgrading.html [L] Code (markup): That way, unless you are not coming from 10.100.0.55 AND you are not accessing upgrading.html, all requests will be rewritten (forwarded, if you will) to upgrading.html
thanks zdrol it works perfectly - the correct syntax though is: RewriteEngine On RewriteBase / RewriteCond %{REMOTE_ADDR} !^88\.209\.173\.81$ RewriteRule ([^/]+) site_offline.html [L] Code (markup): any address requested from that domain will have the content of the "site_offline.html" displayed UNLESS you are coming from the IP address in the rule. .htaccess and site_offline.html should be in the root directory thanks again.
best upload an index.html file with what ever you want your visitors to see. you can access your site thru domainname/index.php