How to quickly put your website to maintenance mode
Sometime we need to put off a website for security reasons. For example when a customer get a malware or the site is hacked and we must organize well to cover all the points that are needed:
Table of Contents
- Clients must reach the website with maintenance page, put there all usefull information.
- SEO problem: the pages must not have a redirect 301 or 302!! error 503 is a better solution.
- You need to exclude yourself for diagnostic purpose.
Time Needed : 0 days 0 hours 3 minutes
These steps work with Apache:
Create an HTML page like that maintenance.html on you root’s site.
<html> <body> <h1>This site is temporarily under maintenance.</h1> <h2>Will be back soon, please come back later.</h2> </body></html>
Enter this text on top of your .htaccess .
#MAINTENANCE-PAGE REDIRECTErrorDocument 503 /maintenance.html<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REMOTE_ADDR} !=<YOURIPADDRESS> RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC] RewriteRule ^.*$ - [R=503,L]</IfModule>
Happy hunting!
Now you can find and fix the problem!When you finished remove all lines you put on your .htaccess file
ErrorDocument 503 /maintenance.html means that if client get a 503 error will be redirect to maintenance page
RewriteCond %{REMOTE_ADDR} !=<YOURIPADDRESS> helps you to reach your site!
RewriteRule ^.*$ - [R=503,L] put a 503 error without change the URL.