How to temporally disable a website?

Sometimes you may want to temporally shut down your website to do some maintenance work. Stopping the httpd service may not be a good choice for you because you have other websites on the same host. You may think you can create a “site under construction” page in the website’s directory but that is not enough if your website has many pages. Even your website has only one page, using a “site under construction” page is not good as it will do harm to SEO. The correct way to turn off a website temporally for maintenance is to use a .htaccess file to return 503 to requests for any page of the website:

ErrorDocument 503 /503.html
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/503.html$
Header always set Retry-After “Wes, 31 May 2017 12:00:00 GMT”
RewriteRule .* – [R=503]

You’ll also need to create a 503.html and put it in the root directory of your website, which contains the content users will see in the browser when they visit your website. For any page other than 503.html, Apache will produce a 503 response with a Retry-After header

Retry-After: Wes, 31 May 2017 12:00:00 GMT

This is good to SEO as search engine robots will know this is a temporary issue and will check it later.


Posted in tips of hosting