by Manoj Kumar

Install WordPress MU with www.

WordPress MU, by default, does not allow “www.” to be put during installation. These four characters just seem out of place but also there are instances where one might require the same.

Recently Charles (ckck) sent a message on configuring his domain with www. I found his reasons to be valid and decided to assist him on this query.

I initially made changes to the main database and it worked. In my view, however this was not satisfactory as one had to search in all the tables and edit the given domain name in the main database.

An alternate approach was identified where certain files in the original source were modified before proceeding with the installation. These files are wpmu-settings.php and index-install.php . After making the necessary changes , you can proceed with the installation.

Method 1 – make changes in the main database

1. Install WordPress MU without www.

2. While installing, choose sub-directories option.

3. Check your installation by clicking on “Hello world!” post as well as by login to your admin interface. Make sure it installed properly.

4. Login to your MySql database where you have installed you WordPress MU

5. Open database and edit all records where your domain name exists without www. (Add www. in all). You can use search to find out this.

6. Edit you wp-config.php exists in the main folder of your WordPress MU and change

define(’DOMAIN_CURRENT_SITE’, ’YourDomain.com’ );

to

define(’DOMAIN_CURRENT_SITE’, ’www.YourDomain.com’ );

7. Edit the “wpmu-setting.php” file exists in the main WordPress MU directory.

Comment line no. 9 and 10

9
10
if( substr( $domain, 0, 4 ) == ‘www.)
  $domain = substr( $domain, 4 );

Your installation should work .

Method 2 – Modify Files before installing

1. Open wpmu-settings.php

comment line no. 9 and 10

9
10
 if( substr( $domain, 0, 4 ) == ’www.)
 $domain = substr( $domain, 4 );

2. Open index-install.php

comment line no. 514 and 515

514
515
 if( substr( $domain, 0, 4 ) == ’www.)
 $domain = substr( $domain, 4 );

comment line no. 652,653,654,655 and 656

652
653
654
655
656
 if( substr( $_POST[ 'basedomain' ], 0, 4 ) == ’www.) {
 printheader();
 nowww();
 continue;
 }

comment line no. 665

665
 $_SERVER[ 'HTTP_HOST' ] = str_replace( ’www.,', $_SERVER[ 'HTTP_HOST' ] ); // normalise hostname - no www.

3. Install wordpress mu with www.youdomainname.com

It should work fine.

Let me know if it worked for you or you have any other comments.

Categories: Tweaks - WordPress MU
Kapil at 15:06 on 2 March 2009

Hi Manoj,

Its very informative, a bit technical for me though…

Looking forward for more posts from you ;)

Cheers!

[...] He has one other method that may work for you if this one doesn’t. See his blog at http://manojkumar.org/install-wordpress-mu-with-www/. [...]

admin.dominios at 01:13 on 6 March 2009

Dear Sirs:

Is there any possible way to use www after WPMU installation ? 2 Method way.

In our case we would like to avoid to unisntall our many installations.

Best regards,

Manoj Kumar at 10:49 on 6 March 2009

You can use first method in that case. I think it will work fine for you.

Greg at 21:15 on 16 March 2009

Thank you so much! This worked great!

[...] ist oder nicht, darüber kann man sicherlich streiten. Technisch ist es nicht notwendig. Es gib mehrere Möglichkeiten, das “www” vor oder nach der Installation von WPMU hinzuzufügen. Eine [...]

The Big K at 22:56 on 7 April 2009

Can you help with this: http://buddypress.org/forums/topic.php?id=2006

I need help with it badly :(

[...] na to pytanie znalazłem na blogu Manoj Kumara. Poniżej prezentuję możliwe do zastosowania metody [...]

Jessicaacuby at 22:59 on 10 May 2009

I love it! That is way cool man! The steps weren’t that complicated too, which is great.

[...] Install WordPress MU with www Manoj Kumar Posted by root 59 minutes ago (http://manojkumar.org) 2 open index install php comment line no 514 and 515 manoj kumar powered by wordpress theme adopted from smells like facebook Discuss  |  Bury |  News | Install WordPress MU with www Manoj Kumar [...]

los at 08:14 on 19 June 2009

this worked great. Thanks!! I had installed a 1.3 version and had to reinstall everything from scratch to update to 2.7, needless to say I forgot the steps I took to get the www version to work, but thankfully someone actually documents their work. Thanks again!!

Pamela Mooring at 22:30 on 6 July 2009

clkJXi thank you dear friend,

Tanner Williamson at 21:55 on 22 September 2009

Many thanks for your excellent guide. Very simple to follow, and was exactly what I needed, rather than trying to hack up a .htaccess rule for just my main domain.

Ramesh Menon at 09:53 on 27 September 2009

Hi,

Thanks for the information. Your method works fine. However, when I am registering a new user, the user’s blog comes up without the www. Where can I fix this?

Best Regards
Ramesh J Menon

Ramesh Menon at 11:56 on 27 September 2009

Figured it out. I had upgrade to 2.8.4a. Wp-settings.php had changed to the original strip www.
Changed it back
Best Regards
Ramesh J Menon

Ken Dreyer at 04:45 on 21 October 2009

Thanks Manoj; these instructions were very helpful. I would also like to document that this bug is filed at http://trac.mu.wordpress.org/ticket/901. Let’s hope this gets changed in upstream WPMU.

Peter at 21:06 on 22 October 2009

I followed the instructions of Method 2 – Modify Files before installing, but unfortunately it does not work … I expect I did not edit the files correctly. Is it possible to provide the edited result files as illustrated? Thank you for that in advance!

Peter at 00:12 on 23 October 2009

Did it all over and … it works like a charm: thank you! (It was as I suspected an editing mistake …)