• Resolved sbarraud

    (@sbarraud)


    Hi all,

    What I want to do it’s pretty basic but seems to be very complicated with WordPress Network (even with Domain Mapping) so I hope someone could help me.

    So I would like to have a network with those sites (blogs):
    http://www.mydomain.com (the main site)
    fr.mydomain.com
    de.mydomain.com
    toto.mydomain.com

    I know it’s possible to do mydomain.com as main site but I want to keep http://www.mydomain.com (please don’t tell me that is obsolete so why I want to keep it etc…).

    The solution that I’ve found it’s to create the main site with www so http://www.mydomain.com and then create subdomain for example fr.www.mydomain.com and finally use domain mapping to redirect fr.www.mydomain.com to fr.mydomain.com. Not the best probably.

    I’ve also found this topic (https://wordpress.org/support/topic/redirecting-non-www-to-www-revisited?replies=11) in which Andrea Rennick said that it’s possible to create an entry (with www) for domain mapping with the same Site ID as the main site entry… but I cannot do that. It’s still possible?

    I really hope that someone could help me because I cannot imagine to be the first who want to do that.

    Thanks in advance,
    Sylvain

Viewing 5 replies - 1 through 5 (of 5 total)
  • here, its pretty old article but this is what i did in one of my active projects.
    adding www to multisite
    blame the seo-bs back in the day for being so anti-www prefix

    access your mysql database and in wp_options browse for:
    siteurl: and change it to http://www.mydomain.com
    home:  and change it to http://www.mydomaincom
    for wp_blogs browse for your main domain and change it to
    www.mydomain.com
    (no http for this)

    in your wp-config file

    define ('DOMAIN_CURRENT_SITE', 'www.mydomain.com' );
    define ('PATH_CURRENT_SITE', '/' );
    define ('SITE_ID_CURRENT_SITE', 1 );
    define ('BLOG_ID_CURRENT_SITE', 1 );
    define( 'NOBLOGREDIRECT', 'http://www.mydomain.com' );

    the thing is you just have edit some stuff on your database and wp-config file, the caveat is that you wont able to access your site using its bare naked domain name.
    make sure to look for the tables that contain your bare naked domain with it on your database.

    to fix broken link images, just reattactched them by editing a post. wordpress will use your new siteurl.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    You absolutely cannot domain map www to the primary domain of your network. You can’t map anything to it. Just put that aside.

    Do what faospark said and toss in a .htaccess rule for it:

    # Force the "www."
    RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

    That SHOULD cover things.

    blame the seo-bs back in the day for being so anti-www prefix

    It’s not to do with SEO for me, it’s what www used to stand for and no longer does that irks me. Also it’s a longer URL.

    Thread Starter sbarraud

    (@sbarraud)

    Thanks guys!

    It seems that it works with the latest version of WordPress without doing anything special.

    For interested people, here is what I did:

    – Install wordpress with http://www.mydomain.com
    – Enable multisite define('WP_ALLOW_MULTISITE', true);
    – Create network (it’s written that you should replace your siteurl by mydomain.com but I haven’t because I want to keep the “www”).
    – Add the config and htaccess:

    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', true);
    define('DOMAIN_CURRENT_SITE', 'www.mydomain.com');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
    RewriteRule ^(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]

    – Create new site with mynewsite.mydomain.com (the domain doesn’t have the www anymore)

    Thanks again anyway 🙂

    @sbarraud mark the topic solve 🙂

    Thread Starter sbarraud

    (@sbarraud)

    yes… sorry about that

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘main site with www’ is closed to new replies.