WordPress MU Stubornly Forces No WWW Subdomains – Huh? And How To Fix It.
Let me preface by saying that I very much prefer the look and simplicity of naked domains – i.e. http://example.com vs http://www.example.com – and everything I do I try to use naked domains.
The devs working on WordPress Multi-User, or MU, have similar thoughts on the no-www domain preference, but do they kindly make their case with suggestions and education? No, they ram the no-www mantra down your throat, hardcoding multiple and irreversible blocks of code in the setup and load scripts that expressly forbid a user from ever using a www. subdomain! Their reasoning for this seamingly arbitrary dictation? I can’t seem to find one that isn’t based on their own personal preferences.
For the most part, the MU community seems to agree with this decision as a sound one! Wow, does anyone else see a major lapse in judgement here? Here’s an abbreviated forum thread on the subject, names removed to protect the innocent:
Smart Person: WordPress MU forcess no-www. This is a huge mistake!
Person 1: Set up your server to forward www to non-www, everything will be ok
Smart Person: No, it won’t. Why should I change my entire site structure to accomodate this arbitrary decision?
Person: Do redirects and xml sitemaps so that google re-indexes your site with no www.
Smart Person: You’re missing the point! I want a subdomain!
Person: So install MU on a subdomain like ‘blogs.example.com’
Smart Person: *sigh* ok, how about this subdomain – ‘www.example.com’!?
It just seems so silly to me that they have an unfounded, non-technical bias against ‘www’ as a subdomain. They support any other subdomain except for ‘www’!
A hack to fix this on install
Warning: This is definitely just a ‘hack’ and will most likely break on upgrade! And unfortunately, I was unable to revers the no-www effects after a complete installation, this has to be done before a fresh install.
This is for version 2.6.
In index-install.php make the following changes:
# comment out lines 238, 239:
//if( substr( $_SERVER[ 'HTTP_HOST' ], 0, 4 ) == 'www.' )
//$hostname = str_replace( "www.", "", $_SERVER[ 'HTTP_HOST' ] );
# comment out lines 365, 366:
//if( substr( $domain, 0, 4 ) == 'www.' )
//$domain = substr( $domain, 4 );
# comment out lines 475-482:
/*
if( substr( $_POST[ 'basedomain' ], 0, 4 ) == 'www.' ) {
printheader();
nowww();
continue;
}
*/
# comment out line 489:
//$_SERVER[ 'HTTP_HOST' ] = str_replace( 'www.', '', $_SERVER[ 'HTTP_HOST' ] );
In wpmu-settings.php make the following changes:
# comment out lines 9, 10:
//if( substr( $domain, 0, 4 ) == 'www.' )
//$domain = substr( $domain, 4 );














edkohler 1:24 pm on December 22, 2008 Permalink
Interesting issue. Non-www domains are pretty sexy, but the cost of switching an entire site's URL structure is something that should not be taken lightly. Nice workaround to fix what shouldn't be broken in the first place.
edkohler 1:24 pm on December 22, 2008 Permalink
Interesting issue. Non-www domains are pretty sexy, but the cost of switching an entire site's URL structure is something that should not be taken lightly. Nice workaround to fix what shouldn't be broken in the first place.
Tiny 5:16 am on March 8, 2009 Permalink
Many thanks.
I've been working on this problem for several days, until I read your article.
No-www does make no sense!!
Tiny 5:16 am on March 8, 2009 Permalink
Many thanks.
I've been working on this problem for several days, until I read your article.
No-www does make no sense!!
Tiny 12:16 pm on March 8, 2009 Permalink
Many thanks.
I've been working on this problem for several days, until I read your article.
No-www does make no sense!!