0
help

How To Create A WordPress Site Behind A Live Site

By October 28, 2015No Comments

First of all, install WordPress where it will be once the site goes public. Verify that the wordpress installation is working correctly and then proceed to rename the index.php file to index_wp.php.

Then create a new file on that same root folder. Name it index.php and paste the following code in.

<?php
session_start();

if (isset($_POST['uc']) && $_POST['clientKey'] == '123456'){
$_SESSION['bypass_under_construction'] = true;
}elseif(isset($_GET['stop'])){
$_SESSION['bypass_under_construction'] = null;
}

//check if current session is bypassing under construction page
if (isset($_SESSION['bypass_under_construction'])){
//pull index_wp.php. This allows normal execution of your WordPress Installation
include('index_wp.php');
?>
<div style="background-color:#454545;margin:0px;padding:2px;color:#FFFFFF;font-family:trebuchet ms;font-size:12px;">
You are currently bypassing your WordPress under construction page. -
<a href="index.php?stop=true" style="color:#FFFFFF;">Log Out</a>
</div>
<?php
}else{
include('underconstruction.html');
?>
<div onclick="ucShowForm();" style="background-color:#454545;margin:0px;padding:0px;color:#FFFFFF;font-family:trebuchet ms;font-size:12px;">
<a href="#" style="color:#FFFFFF;" id="ucShowFormLink" onclick="ucShowForm();" >&nbsp;&nbsp;*</a>
<form method="POST" action="index.php" id="clientLoginForm" style="display:none;margin:3px;padding:3px;">
<input type="hidden" name="uc" value="true" />
<label for="clientKey">Client Key:</label>
<input type="password" name="clientKey" id="clientKey" />
<input type="submit" value="Enter" />
</form>
<script type="text/javascript">
function ucShowForm(){
javascript:document.getElementById('ucShowFormLink').style.display = "none";
javascript:document.getElementById('clientLoginForm').style.display = "block";
}
</script>
</div>
<?php
}
?>

Finally create a new file on that same root folder named underconstruction.html. On this file you can create your custom under construction page.

When you try to access your blog you will get your under construction page and on the bottom you will see a dark gray bar with an “*” on the left. If you click this a form shows up where you enter an access key (see below how to change the access key) which you can give your clients to check up on the design progress and keep the site hidden from the general public.

Once logged in you will see your wordpress installation. You can work on it with out having to rename paths and files and transfer installations and databases and and and and…. When you want to unleash your site to the world just rename index.php to index2.php and index_wp.php to index.php.

How to change the access key

In the source code for this script find the line that says

[su_highlight]if (isset($_POST[‘uc’]) && $_POST[‘clientKey’] == ‘123456’){

}[/su_highlight]

And set the clientKey value to whatever you want. The default value is ‘123456’.

Hope you find it useful, let me know what you think or would like to see for this script. If enough people find it useful I can turn it into a wordpress plugin.

Original post by: http://www.mecannical.com/2010/tutorials/how-to-set-up-a-wordpress-under-construction-environment-v-2-0/

All rights reserved CNFdesigns.