These days, I pretty often port a static site to a WordPress-based site. Once I have finished developing a WordPress site on a test server, I want to install it in the current domain of the website, but without affecting the old static site, until the site appears live.
My idea is to move the current website without WordPress to the /old/ folder and get all requests to rewrite to this folder (and therefore for SEO purposes, keeping all the URLs the same).
To allow myself and other authorized users through I want to check the cookie (which will be set via a simple "php file" login, because I can not rely on static IP addresses), or if the current date and time is after the current date, then let the rewrite rules WordPress takes its course to provide access to the WordPress website.
It will also allow me to add a simple countdown timer on the current or old site, after which the new site will be automatically transferred to a live date.
My simple login.php script looks 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 best way to achieve this could be as follows, but it doesn’t work (I get an internal server error). The first section checks if there is a cookie for login, and if not, and the current date and time until 20:00 on July 20, 2012 will rewrite all requests in the /old/ folder. I changed the rewriting section of WordPress 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?