Chris Hardcastle

Techical developer for websites in London

Wordpress site preview

Once you have finished building a Wordpress based website. Wouldn’t it be great to test it on the live website host, without interrupting any existing files or pages? This is just the kind of scenario that I have been asked about in the past. So, I have recently developed my own suggestion as to how this can be achieved.

Once your Wordpress database has been set up and all the files for the site are in place. The next step is to replace the existing index.php / html file with the one from the root of your Wordpress build. From that moment Wordpress with be in control of all incoming requests to your site.

Given that the existing home page has to remain the same until your ready to “activate” the new one. You can modify the .htaccess file so the Wordpress site will only respond if the homepage has been called with a particular query string. This means you can test the Wordpress build without interrupting the main index page.

In order to do this, you have to modify your .htaccess file in the website root. Below is the modified .htaccess file, take a backup before testing!


# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/wp-content/
RewriteCond %{REQUEST_URI} !^/wp-includes/
RewriteRule . /$1/?test=true [L]
# END WordPress

Replace your existing .htaccess file with the code above and you are half way. Next modify your index.php in the wordpress site.


if(isset($_GET["test"])){
define('WP_USE_THEMES', true);
/* Loads the WordPress Environment and Template */
require('./wp-blog-header.php');
}else{
/* Your holding page HTML / include file */
}

You can redirect to, or include the existing index page within the else clause as described above. The links should still be intact because the .htaccess file is appending your url with the required query string.

So when you visit the site your existing homepage should remain the same. When you visit http://yoursite.com/?test=true your wordpress site should wake up and run accordingly.

Tags: , ,

One Response to “Wordpress site preview”

  1. Harbans Lal Gera – I know this is off topic but need help with Vista

    Thanks,
    Harbans Lal Gera

Leave a Reply


My Twitter updates

  • hardcastle There's new examples I've not seen already on the #raphaeljs framework website. Pretty cool!
  • hardcastle Wow, couch.io just got a new design and content! #couchdb
  • hardcastle @mark_xDDD it feels very stable. Installation was perfect. It's only good if it fits your needs!
  • hardcastle @mark_xDDD I'm installing kubuntu 10.04 tonight!

youTube videos

Luke gives a half smile

Luke gives a half smile

This video was uploaded from an Android phone.

Duration: 00:23

Views: 85


Lukes first rattle holding experience

Lukes first rattle holding experience

This video was uploaded from an Android phone.

Duration: 00:44

Views: 26