VPS business hosting starting at $29.95/24/7 premium technical support

How to put a site in maintenance? [Apache web server]

ErrorDocument 403 /index.html
DirectoryIndex index.html
<Files ~ "index\.html">
	Order Allow,Deny
	Allow from all
</Files>
Deny from all

Content of your .htaccess file

If you want to whitelist any IP, use this

ErrorDocument 403 /index.html
DirectoryIndex index.html
<Files ~ "index\.html">
	Order Allow,Deny
	Allow from all
</Files>
Order Allow,Deny
Allow from xx.xxx.xx.xx
Deny from all

Here is a sample htaccess for a wordpress website with 1 IP whitelisted 4.129.45.44 and all others are banned. So you only will be able to load the website while everyone else will see contents of index.html with HTTP Status code 403

ErrorDocument 403 /index.html
DirectoryIndex index.php
<Files ~ "index\.html">
    Order Allow,Deny
    Allow from all
</Files>
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^4\.129\.45\.44$
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REMOTE_ADDR} !^4\.129\.45\.44$
RewriteRule . /index.php [L]

Allow from 4.129.45.44
Deny from all

Author: Harshvardhan Malpani

PHP Developer based in New Delhi, India. Working as a freelance web developer providing server deployment, website development and maintenance services.

Leave a Reply

Your email address will not be published.