WordPress.org

Ready to get started?Download WordPress

Forums

WP_HOME and WP_SITEURL (6 posts)

  1. omiron
    Member
    Posted 9 months ago #

    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?

  2. 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?

  3. omiron
    Member
    Posted 8 months ago #

    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

  4. 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.

  5. omiron
    Member
    Posted 8 months ago #

    Thanks for reply

    So you still have seperate DBs per environment?

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

Reply

You must log in to post.

About this Topic