There is probably a feature in MODX I overlooked for doing this but i thought that others may find this useful.
I had a customer who wanted to make sure that only certain people could test the new MODX site and all other visitors were sent to the old site.
So I added this code below into the beginning of the index.php file, What it does is checks to see if the user has a cookie called 'istest', if the cookie is not set to 1 then the user is redirected to the old site home page.
To enable
www.mysite.com/?test=1
Once set, you can use the MODX site as usual and test and develop the site, and visitors will be sent to the old site.
To turn if off so that you are always redirected to the old site.
www.mysite.com/?test=0
There is potential to develop further, sending visitors to the right pages etc...
Glenn
<?php
if (isset($_REQUEST['test']))
{
$istest = $_REQUEST['test'];
setcookie ("istest",$istest, time() + ((3600 * 24) * 30) );
} else {
$istest ='';
if(isset($_COOKIE["istest"]))
{
$istest = $_COOKIE["istest"];
}
}
if ($istest !== '1'){
//redirect if not in test mode
header( 'Location: htt p://www.oldsite.com/page.html' ) ;
}