May 10th, 2008

htaccess rewriting for an “under construction” page.

Quick post. Sorry for the terseness. You're running a site on Apache, and while you're working on it you want the public to see an "under construction" page. The site is visible at a subdomain of your root host, (a typical scenario on Apache, with CPANEL and add-on domains) Your normal redirection htaccess: just the basic rule that canonicalizes the domain...
Options +FollowSymlinks RewriteEngine on RewriteCond %{HTTP_HOST} !www\.example\.com$ RewriteRule ^(.*)$ http://www.example.com/$1 [R=301]
You "Under construction" htaccess: slightly different. it only canonicalizes the domain with the "www" missing, but does not canonicalize the subdomain. Beware - this should be supplemented by some HTTP authentication... it's not perfect for long-term use but it's a great quick hack
Options +FollowSymlinks RewriteEngine on RewriteCond %{HTTP_HOST} ^example\.com$ RewriteRule ^(.*)$ http://www.example.com/$1 [R=301] RewriteCond %{HTTP_HOST} www.example\.com$ RewriteCond %{REQUEST_URI} !/comingsoon\.html$ RewriteCond %{REQUEST_URI} !/.*\.png$ RewriteRule .* /comingsoon.html [R]

Filed under Uncategorized

Leave a Reply