WordPress.org

Support

Support » Multisite » WP_HOME and WP_SITEURL

WP_HOME and WP_SITEURL

  • I used to use these config values when I had a single blog and they were very useful allowing developers to run wordpress on local servers but all pointing to the same DB.

    They seem to be ignored now that I’ve changed to a multisite setup however, is there an equivalent for multisite?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Kind of. But we really don’t recommend messing with that in multisite, because it hardcodes the home/site URLs in the DB.

    Why are you having them all point to the same DB?

    It was easier than having to install databases on every developers laptop. Seems silly to have to have a whole local copy of the DB just to change the domain of the blog url in a few fields

    We use webenv for this.

    if ( function_exists('apache_getenv') && apache_getenv('webenv') ) {
            $webenv = apache_getenv('webenv');
    } elseif ( function_exists('getenv') && getenv('webenv') ) {
            $webenv = getenv('webenv');
    } else {
            $webenv = "default";
    }

    And then

    witch ( $webenv ) {
            case 'local':
                    if ( file_exists( dirname( __FILE__ ) . '/local-config.php' ) ) {
                            include( dirname( __FILE__ ) . '/local-config.php' );
                            break;
                    }
            case 'staging':
                    define('WP_SITEURL', 'http://stage.domain.com');
                    define('WP_HOME', 'http://stage.domain.com');
                    define('WP_DEBUG', false);
                    define('DB_NAME', 'staging');
                    define('DB_USER', 'root');
                    define('DB_PASSWORD', 'root');
                    define( 'DOMAIN_CURRENT_SITE', 'stage.domain.com' );
                    break;
            default:
                    define('WP_SITEURL', 'http://domain.com');
                    define('WP_HOME', 'http://domain.com');
                    define('WP_DEBUG', false);
                    define('DB_NAME', 'DBNAME');
                    define('DB_USER', 'DBUSER');
                    define('DB_PASSWORD', 'DBPASS');
                    define( 'DOMAIN_CURRENT_SITE', 'domain.com' );
                    break;
    }

    So you could use that same logic.

    Thanks for reply

    So you still have seperate DBs per environment?

    Yeah, because of images for the most part. Multisite hard codes in the URLs in lots of weird ways :/

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WP_HOME and WP_SITEURL’ is closed to new replies.