When you are deploying a new site to the same IP as an existing site you need to keep the public away while you are uploading the files and ironing out any problems.

One way to do this is to create a new document root directory and edit your vhosts configuration, but when you’re using a control panel like Plesk you are asking for trouble if you start messing around with the file system.

A much easier way, when using Apache, is to create a splash page and redirect traffic from IP addresses other than your own while you are busy uploading and debugging.

This can be done very simply using the .htaccess file:

1.    Create a directory in your document root directory named “maintenance”
2.    Upload your splash page and all linked files (images, css etc) here
3.    Add the following to your .htaccess file:

##  DOWN FOR MAINTENANCE FOR EVERYONE EXCEPT US  ##
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !99.99.99.99
RewriteRule !^maintenance/ http://www.mydomain.com/maintenance/ [R,L]

Just change the 99.99.99.99 for your own IP and dont remove the slashes. If you have load balanced connections, like us, or developers working from different locations you can add more IPs:

##  DOWN FOR MAINTENANCE FOR EVERYONE EXCEPT US  ##
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !99.99.99.99 [OR]
RewriteCond %{REMOTE_ADDR} !88.88.88.88 [OR]
RewriteCond %{REMOTE_ADDR} !77.77.77.77
RewriteRule !^maintenance/ http://www.mydomain.com/maintenance/ [R,L]

I’ve used a 302 redirect because the move is temporary.

Google+

Comments

comments

This entry was posted in Blog. Bookmark the permalink.