<?php
/*
Plugin Name: Sandbox Relocator
Plugin URI: http://www.ben-xo.com/v6/wordpress-relocate-plugin
Description: Relocate your sandbox automagically, without having to jump through ridiculous hoops. Just define('RELOCATE', true) in wp-config.php to activate
Author: Ben XO
Version: 0.2
Author URI: http://www.ben-xo.com/
*/ 

if ( defined('RELOCATE') && substr($_SERVER['PHP_SELF'],-13) == '/wp-login.php' ) { // Move flag is set

    
if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) )
            
$_SERVER['PHP_SELF'] = str_replace$_SERVER['PATH_INFO'], ''$_SERVER['PHP_SELF'] );

    
$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' 'http://';
    if ( 
dirname($schema $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != get_option('home') ) {
        
$__the_url dirname($schema $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
        
update_option('siteurl'$__the_url);
        
update_option('home'$__the_url);

    }
}

?>