<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Chris Hardcastle &#187; .htaccess</title>
	<atom:link href="http://chrishardcastle.co.uk/tag/htaccess/feed" rel="self" type="application/rss+xml" />
	<link>http://chrishardcastle.co.uk</link>
	<description>Facebook App and Website Developer</description>
	<lastBuildDate>Wed, 23 Feb 2011 00:42:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>WordPress site preview</title>
		<link>http://chrishardcastle.co.uk/wordpress-site-preview</link>
		<comments>http://chrishardcastle.co.uk/wordpress-site-preview#comments</comments>
		<pubDate>Wed, 17 Jun 2009 00:26:13 +0000</pubDate>
		<dc:creator>chris.hardcastle</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[.htaccess]]></category>

		<guid isPermaLink="false">http://chrishardcastle.co.uk/?p=48</guid>
		<description><![CDATA[Once you have finished building a WordPress based website. Wouldn&#8217;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 &#8230; <a href="http://chrishardcastle.co.uk/wordpress-site-preview">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Once you have finished building a WordPress based website. Wouldn&#8217;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.<br />
<span id="more-48"></span><br />
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.</p>
<p>Given that the existing home page has to remain the same until your ready to &#8220;activate&#8221; 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. </p>
<p>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!</p>
<p><code><br />
# BEGIN WordPress<br />
RewriteEngine On<br />
RewriteBase /<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteCond %{REQUEST_URI} !^/wp-content/<br />
RewriteCond %{REQUEST_URI} !^/wp-includes/<br />
RewriteRule . /$1/?test=true [L]<br />
# END WordPress<br />
</code></p>
<p>Replace your existing .htaccess file with the code above and you are half way. Next modify your index.php in the wordpress site.</p>
<p><code><br />
if(isset($_GET["test"])){<br />
    define('WP_USE_THEMES', true);<br />
    /* Loads the WordPress Environment and Template */<br />
    require('./wp-blog-header.php');<br />
}else{<br />
    /* Your holding page HTML / include file */<br />
}<br />
</code></p>
<p>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.</p>
<p>So when you visit the site your existing homepage should remain the same. When you visit http://yoursite.com<strong>/?test=true</strong> your wordpress site should wake up and run accordingly. </p>
]]></content:encoded>
			<wfw:commentRss>http://chrishardcastle.co.uk/wordpress-site-preview/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

