admin管理员组

文章数量:1406951

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

For expample if I have two domains www.domain-one and second www.domain-two, 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' )

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')
    define('COOKIE_DOMAIN', 'www.domain-two');

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?

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

For expample if I have two domains www.domain-one and second www.domain-two, 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' )

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')
    define('COOKIE_DOMAIN', 'www.domain-two');

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 edited Nov 30, 2012 at 15:24 Roman asked Nov 30, 2012 at 15:14 RomanRoman 3292 silver badges8 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

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.

本文标签: subdomainsHow to set up Wordpress Multisite on multiple domains without plugin