How to set up WordPress Multisite on multiple domains without plugin?

How to set up WordPress Multisite, sub-folder setup, on multiple domains without plugin?

For expample if I have two domains www.domain-one.com and second www.domain-two.com, i would like to have sites like: www.domain-one.cz – site in root, www.domain-one.cz/anothersite/ – site in subfolder of first domain, then the same posibilities on the second domain, is it posible?

Read More

Actually i could do it on multiple domains but with change of one condition in wp-includes/ms-settings.php on line 72:

if ( $blogname != '' && ! in_array( $blogname, $reserved_blognames ) && ! is_file( $blogname ) && $domain != 'www.domain-two.com' )

and to be able to log into those sites you have to also put some aditional code to settings.php (this seems not necessary for new wordpress):

if($_SERVER['HTTP_HOST'] == 'www.domain-two.com')
    define('COOKIE_DOMAIN', 'www.domain-two.com');

With this, quiite simple solution, you can have multiple sites but no sites with subfolders within those aditional domains, you can have subfolder sites only for main domain (and then multiple aditional domains).

Actually if there is no option to do this without plugin and without changing code of core, if there option to do ti with change of core? Or is there some plugin which can do exactly this? What about sunrise.php is it posible with this?

Related posts

Leave a Reply

1 comment

  1. It is important that you set the constant COOKIE_DOMAIN in the wp-config.php

    define( 'COOKIE_DOMAIN', '' );
    

    The value must be empty, otherwise WordPress will always set it to your network’s $current_site->domain and you won’t be able to login into any of the other sites.

    From core:

    /**
     * @since 2.0.0
     */
    if ( !defined('COOKIE_DOMAIN') && is_subdomain_install() ) {
       if ( !empty( $current_site->cookie_domain ) )
           define('COOKIE_DOMAIN', '.' . $current_site->cookie_domain);
       else
           define('COOKIE_DOMAIN', '.' . $current_site->domain);
    }
    

    Now you can set a domain in the settings of each site in the network.

    Sceenshot Settings