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