Need help? Check out our Support site, then

HOWTO: run 1 blog from 2 URLs / run 1 database with 2 sets of files

  1. You know the problem. You want to work on your wordpress theme offline, on your own personal copy of the blog; but you want to keep all the files in sync with your web site, and use the same database.

    But wordpress insists on linking all the links back to your real, online blog. How to tell it to use the URL of your local blog locally, and your remote blog remotely?

    Here's a hack to make wordpress pick up the URL for itself, every time!

    open up wp-includes/functions.php and find the part which says:

    /* Options functions */

    function get_settings($setting) {
    global $wpdb;

    $value = wp_cache_get($setting, 'options');

    if ( false === $value ) {
    if ( defined('WP_INSTALLING') )

    and change it to say this:

    <br /> /* Options functions */

    function get_settings($setting) {
    global $wpdb;

    $value = wp_cache_get($setting, 'options');

    /* Ben XO's siteurl hack */
    if( 'siteurl' == $setting or 'home' == $setting ) {

    $_REAL_SCRIPT_DIR = realpath(dirname($_SERVER['SCRIPT_FILENAME']));
    $_REAL_BASE_DIR = realpath(dirname(__FILE__).'/..');
    $_MY_PATH_PART = substr( $_REAL_SCRIPT_DIR, strlen($_REAL_BASE_DIR));

    ? substr( dirname($_SERVER['SCRIPT_NAME']), 0, -strlen($_MY_PATH_PART) )
    : dirname($_SERVER['SCRIPT_NAME'])

    $value = 'http' . ($_SERVER['HTTPS'] ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $INSTALLATION_PATH;
    /* end Ben XO's siteurl hack */

    if ( false === $value ) {
    if ( defined('WP_INSTALLING') )

    it uses a trick i posted on the PHP comments page, here:

    happy developing!

  2. I'm afraid you're on the wrong site. You need to be over here. These are the forums for blogs hosted at, not for those who host their blogs elsewhere. (And if you're editing your theme, then you're elsewhere as we are currently unable to)

    Good luck,

  3. ah har. my apologies. it's not immediately obvious. i was wondering my i had to log in multiple times... there does seem to be a bit of ambiguity between a blog from and a blog from :p

Topic Closed

This topic has been closed to new replies.

About this Topic