.htaccess redirect to maintenance - under construction page

Submitted by Tim on 17 Jan 2011 - 10:37

For simple redirect while doing maintenance on websites like upgrades or emergency fixes I put a site in maintenance by adding the next few lines to my .htacces RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123 RewriteCond %{REQUEST_URI} !(\.(gif|jpg|css)$|^/maintenance\.html$) RewriteRule ^(.*)$ /maintenance.html [R=302,L] Ofcourse change the 123\.123\.123\.123 to your ip address and create a maintenance.html. This .htaccess will still serve images and css normally so you can use them in your maintenance page. If you want to add more ip adresses just duplicate the line: RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123 and change the ip.

Add new comment

The content of this field is kept private and will not be shown publicly.

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.