Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

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?

share|improve this question

1 Answer 1

Important is, that you set the constant COOKIE_DOMAIN in the wp-config.php

`define('COOKIE_DOMAIN', '' );`

The value must 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. enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.