Robert Kern
PHP Web Developer
My name is Robert Kern.
I am a PHP developer from Auckland, New Zealand.
Browse through some of my web development projects, or get in contact with me if you are interested in hiring my php web development services.

Search

  • Topics

    • Honduras (25)
    • Hosting (3)
    • How to (9)
    • iphone (11)
    • Mac (8)
    • Movies (1)
    • Off Topic (10)
    • PHP (8)
    • Recipes App (12)
    • Servers (1)
    • Software (8)
    • Subversion (4)
    • Technology (4)
    • Uncategorized (1)
    • Videos (8)
    • Web Development (19)
      • Security (2)

 

Archives

  • March 2010
  • December 2009
  • November 2009
  • October 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • July 2007
  • Home
  • Web development
  • PHP
  • Projects
  • Contact me
...
  • In Honduras
« More photos
Frondiz CMS – Move to new server »

Redirect to maintenance page

Home > Hosting > Redirect to maintenance page

I recently had to move a website to a new server.  While the DNS changes rolled over, I didnt want people to be able to access the site on the old server as I had already taken a backup and didnt want any more changes to be made.

I used a .htaccess file to redirect any request on the old site to a maintenance page:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/maintenance\.php$
RewriteRule ^(.*)$ /maintenance.php [R=307,L]

The above code redirects everything except the maintenance.php page to the maintenance.php page.

Its very useful to use scripts like this even when performing general maintenance on your site.  You could get even trickier by allowing your IP address to access the site while still blocking everyone else.  That way you can make sure your updates are working properly before ‘turning the site back on’.

Tags: Hosting, linux, mod_rewrite, PHP, server

This entry was posted on Wednesday, July 30th, 2008 at 4:53 am and is filed under Hosting. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a comment

© 2004-2010 Robert Kern, owner of Frondiz, need Hosted Subversion? | Design by Jarred Bishop | WordPress