I find myself migrating a static site to a WordPress-based website fairly frequently these days. Once I've finished development of the WordPress website on a test server, I then want to install it on the current website domain, but without affecting the old static site- until the site goes live.
My idea is to move the current non-WordPress website to a folder /old/
and get all requests to rewrite to this folder (and so for SEO purposes keeping all the urls the same).
To allow myself and other authorized people through I want to check for a cookie (that will be set via a simple "login" php file since I can't rely on static IP addresses) or if the current date and time is after the live date then let the WordPress rewrite rules take their course to give access to the WordPress website.
This will also allow me to add a simple countdown timer on the current or old site after which the new site will go live automatically at live date.
My simple login.php script is like this:
<?php
setcookie("login", "loggedin", time()+3600,"/");
?>
<h3>Welcome, you are logged in</h3>
<p><a href="/">Click here to visit the home page</a></p>
I thought the following might be the best way to acheive this, but it doesn't work (I get a Internal Server Error). The first section checks to see if the login cookie exists and if it doesn't and the current date and time is before 8pm on July 20 2012 it will rewrite all requests to the /old/
folder. I've modified the WordPress rewrite section to exclude the /old/
folder.
RewriteCond %{HTTP_COOKIE} !^.*login.*$ [NC]
RewriteCond %{TIME} < 20120720200000
RewriteCond %{REQUEST_URI} !^/old/
RewriteRule (.*) http://domain.com/old/$1 [L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/(old/.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Can someone help me with what I want to achieve?