Multiple domain names on WordPress MU

Polish class EN57 EMUs waiting for service in ...
Image via Wikipedia

We’ve been getting up close and personal with WordPress MU for a while now here at Gazette Communications.  To say the least – it has been nice, and painful.  We tested the product for use on one of our two flag ship products for about a month and then went to use it and ran into a bit of a brick wall.

WordPress MU doesn’t support multiple domain names out of the virtual box.  Yup, just sub-domains or domain.com/foldername.  I think we over looked that part in the “testing phase”.

Luckly – we did some searching and our intern at the time (Chaz Beck) found a post by a guy who had accomplished the same task – here is a rundown of what we did to ge tit working.  Not for the faint at heart – and by all means, please make a backup before you try.

For setting up the multiple domains under one WordPress MU installation, credit must be given to Richard Bui @ http://bui4ever.com/ for his excellent step by step guide. His guide helped create these instructions.

Warning: Manual database manipulation ahead.  :)

Prerequisites

Sub-Domains, Not Sub-Directories.
You need Subdomains being used instead of subdirectories for WordPress MU (We tried to use subdirectories but the login ability failed).

To turn on subdomains go to: http://welcome.totheinter.net/2009/05/06/changing-wordpress-mu-from-subdomains-to-subdirectories/ for instructions.

The main thing is setting:

define(‘VHOST’, ‘yes’);

->inside wp-config.php – this will make the switch from sub-directories to sub-domains

Domain Names:
It is assumed that you have setup the domains that are to be used, Richard Bui has some instructions on some of this [steps 1-11].

The Steps

  1. Create the blogs that you want use if you haven’t done so already (Site Admin >Blogs > Add Blog).
  2. Access your database that WordPress MU uses through PhpMyAdmin (or other tool).
  3. Navigate to wp_#_option where # is the id for the blog you want to use with a different domain (hint: the siteurl in the table will say the name of the blog).
  4. Change the siteurl, home, and fileupload url to your new domain, for the fileupload url keep the /file at the end of the url. Also make sure you put a forward slash (/) at the end of siteurl and home.
  5. Navigate to wp_blogs, click on the domain you are changing. Edit the blogs you are switching to a domain. Put in the following changes:
    • site_id = blog_id
    • domain = yournewdomain.com
    • path = /

    Write down the blog_id for later use

  6. Navigate to wp_sitemeta, copy the meta_value for site_admins meta_key. The stuff you need to copy looks something like this:a:1:{i:0;s:5:”admin”;}
  7. Inside the wp_sitemeta table, copy the meta_value for illegal_names.
  8. Navigate back to wp_sitemeta and go to the last page, copy the last meta_id value
  9. Insert a new entry into the wp_sitemeta table with these values:
    • meta_id = step 8’s value + 1
    • site_id = step 5’s value
    • meta_key = site_admins
    • meta_value = step 6’s value
  10. Insert a new entryinto wp_sitemeta table with these values:
    • meta_id = step 8’s value +
    • site_id = step 5’s value
    • meta_key = yournewdomain.com
    • meta_value = NULL
  11. Insert a new entryinto wp_sitemeta table with these values:
    • meta_id = step 8’s value + 3
    • site_id = step 5’s value
    • meta_key = illegal_names
    • meta_value = step 7’s value
  12. Go to your new domain to test out if the site worked
  13. Test out the wp-admin of the new domain.Example, http://yournewdomain.com/wp-admin/ <- notice the forward slash at the end, this is important to include otherwise your database won’t be populated correctly (first time accessing wp-admin only, after that you can forget about the last forward slash)
  14. Look at the wp_sitemeta table and make sure a bunch of new entries were created in the database, this means everything worked.
  15. Lastly, update your database with the url of the new domain:
    • UPDATE wp_#_posts SET guid = REPLACE (
      guid,
      ‘http://exampleoldsiteurl.com’,
      ‘http://examplenewsiteurl.com’;|
      and
      UPDATE wp_#_posts SET post_content = REPLACE (
      post_content,
      ‘http://oldsiteurl.com’,
      ‘http:// newsiteurl.com’;

    Where # is the blog_id value from step 5

Again – this is not for the faint at heart, or one that is scare of manually manipulating the database.  But I will tell you we have three different domain names running all under one install of MU.  So – that is a real time saver.

References:

http://bui4ever.com/2007/06/wordpress_mu_with_domain_mapping/

http://bavatuesdays.com/multiple-domains-on-wpmu-mission-accomplished/

http://welcome.totheinter.net/2009/05/06/changing-wordpress-mu-from-subdomains-to-subdirectories/

http://codex.wordpress.org/Changing_The_Site_URL#Domain_Name_Change

Enhanced by Zemanta
Both comments and pings are currently closed.

2 Responses to “Multiple domain names on WordPress MU”

  1. Xeon says:

    Hello,

    I got to step 12 without difficulty, even at the level of steps 9, 10 and 11, these entries were already in the database.

    The problem is: when I go to the new address and I try to connect, impossible! It refuses to connect … I do not know what to do?

    Thank you,
    Best regards,
    Xeon

  2. tom.altman says:

    Sorry I didn’t get back to you sooner…what does it look like when you go to Blog 1’s admin screen? Do you see the “new” blog?

    When looking at the admin screen – you should not see the other blogs after the procedure.

    Let me know – I want to help.
    tom

New Blackberry phones on sale | Thanks to Business Opportunity, Highest CD Rates and Registry Software | Wordpress Blog layouts