The other day, Klint Finley wrote a very good walkthrough of using the new Multisite functionality of WordPress 3.0. In the comments, a lot of people wanted to know how to use your own domain names. Since I’m doing that now, here’s a quick walkthrough/how-to guide.

Step 1: Manual Plugin Installation

The Domain Mapping plugin is not your regular kind of plugin. You cannot install it through the normal Plugins->Add New menu. Well, actually, you can, it just won’t work.

So first, download the plugin manually.

Note: For this tutorial, I will be using the WordPress MU Domain Mapping plugin. However, I am using the trunk version of the plugin. It has fixes in it that you will need for proper 3.0 support. Don’t try it with the regular version. (Note: The regular version works fine. This was originally written before the latest version, or 3.0, was released.)

The plugin has two main files you need to put in the proper places.

Domain mapping php file location

The first file is the domain_mapping.php file. This needs to go into the mu-plugins folder. The mu-plugins folder is a special folder, which you may not even have yet. Just create it underneath the wp-content folder and put that file into it.

Sunrise php file location

The second file is the sunrise.php file. This is a special filename for WordPress. Don’t worry about it, just put it in the wp-content folder.

Step 2: Activate Sunrise

Now you need to edit your wp-config.php file. Add this line of code to it:

define( 'SUNRISE', 'on' );

Simple, really. This will cause WordPress to go load that sunrise.php file and use it.

Step 3: Server info

Now you have to configure the domain mapping plugin so that it knows what it’s doing properly. This is easy to do, really. Go to your main domain’s admin page and log in as a super admin. Then go to the new Super Admin->Domain Mapping menu.

Domain mapping setup screen

Here you have a few different options, but two main ones that count. You can either put in the IP address of your server (as defined in your domain’s main A record) or you can put in a CNAME that points to your server. The IP address is what most people will want to use. If your server uses more than one, you can enter them all here, separated by commas.

Other options on this page:

  • Remote Login – This will make your login pages for all sites redirect to your main site to do the actual login. The benefit of this is that when you log in to one, you log into all of them. The downside is that the URL changes to another domain in order to log in.
  • Permanent redirect (better for your blogger’s pagerank) – This makes your subdomain or subdirectory sites redirect to their domains. You should leave this on.
  • User domain mapping page – Turn this on if you want users to be able to put in their own domains for mapping.
  • Redirect administration pages to blog’s original domain (remote login disabled if redirect disabled) – This makes all admin pages show up on the original domain instead of on the new domains. You need this enabled for remote login to work.

Generally I leave only the middle two on. Remote-login is iffy at best, and I want my new domain name to show up everywhere.

Step 4: Mapping the Domain

There’s a bit of a prerequisite here before you do this. When you buy a new domain, you will need to edit its DNS settings to actually point to your server IP or CNAME or whatever you do to make the domain connect to your server. For me, I just give it a new A record with my server IP in it. Easy.

Update: Okay, so there may be more to it than just that, depending on your host. Every host is different, and you’ll have to talk to your host to make them able to point the domain name at your existing site. How to do this varies from host to host, but the important thing is that when you visit your new domain (before you do this!) then you want it to go to your main site, as is.

There’s two ways you can actually map a domain to one of your sites. The user screen is the simplest way, if you left that option on before. Log into the site you actually want to map to a new domain, then go to Tools->Domain Mapping.

User Domain Mapping Screen

All you really do is put in a new domain and set it as the primary. Simple.

Note that if you didn’t get the domain pointed at your server before doing this, then your site will instantly vanish from the realm of mortal man. Setting the primary domain takes effect instantly. You won’t be able to access the site through the old domain any more.

The other way to set domain mapping is through the Super Admin->Domains menu. Here you’ll find a list of sites and their ID numbers. You can map an id number directly to a domain name here. The Tools approach is a bit easier to use, but this will allow you to map domains without visiting them, as you can access this list from your main domain. You can also correct broken domain mappings from here.

Step 5: Seeing the Mapped Domains

If you go to Super Admin->Sites, you’ll find this type of a listing:

Sites listing

You’ll note that on the right hand side you can see the column showing the mapped domains.

Special Note: See in the picture how I’m using a subdirectory install? That’s relatively new. In older versions of the domain mapping system, you had to use a subdomain installation and wildcard DNS for domain mapping to work. This is no longer the case, domain mapping works just fine with subdirectories.

Conclusion

And that’s how it’s done. It’s not super complex, but it does require some knowledge of DNS and how servers work. If you can successfully set up a multi-site install to begin with, you can probably do this as well. Just be aware that it is slightly finicky, and know that you will break your site if you put in the wrong settings somewhere. However, your main domain will always be accessible as long as you don’t try to map it, so you’ll be able to go in from there to correct your mistakes.

Shortlink:

1,194 Comments

  1. […] contributor Otto has written a great guide about domain mapping in Multisite mode in WordPress […]

  2. […] contributor Otto has written a great guide about domain mapping in Multisite mode in WordPress […]

  3. If I don’t set alternative domains to redirect to primary one, the same site will be served for multiple domains roght? Will get_option(“siteurl”) and WP_CONTENT_URL use current domain or will then return the primary domain?

  4. […] and the 3 blogs are hosted on the same installation thanks to the new multisite feature and to the domain mapping plugin. The main regression in those changes is that I’m back to the (new) default theme of […]

  5. […] de mon blog a été l’occasion pour moi de passer à WordPress 3.0 (avec l’option multisite introduite dans cette version). La principale régression est que j’utilise à nouveau le […]

  6. Thanks man for this awesome tutorial! I’ll try it out tonight – perfect timing as I’ve got a multisite project.

  7. where in exactly wp-config.php do you place the code: define( ‘SUNRISE’, ‘on’ );

  8. Your blog is very nice,thanks

  9. i got a problem here.
    i studied your instruction and a couple of tutorials from others. i am pretty sure that i did right of the installation and configuration as you described above, but when i visit a new domain i got the registration page instead of the blog. for DNS setting, i choose Aname and i only point one Aname to the ip address. so could you please give me some tip to fix? thanks for your time.

  10. […] (besser) in die Installation eingebaut werden müssen. WordPress 3.0 Multisite aktivieren und Eigene Domain für Blogs im Blog-Netzwerk (Domain Mapping). Für unerfahrene Blogger wird speziell das Domain-Mapping ein Problem darstellen. Dabei preist […]

  11. Hey.. I tried this but for some reason I can’t get it to work. I have entered the IP and everything like it says, and I have configured my domain with a DNS record. It even says it’s pointing to the right place when I ping it in the terminal. The error I’m getting is service unavailable. Anyone know what might cause this?

    • Okay, so it’s not as simple as all that. You need to have your new domain pointing at your server *and* you need to have your server know about the domain and direct it to your site. How to do that second bit varies depending on the hosting service. A lot of people have good luck with “parking” the domain, but you really need to ask your hosting service how to do this properly.

  12. thanks that was helpful.
    I just enabled multisite and domain mapping and have 2 sites running off 1 install. The only thing is the images URLS is incorrect. How do I fix that?
    the images are in /public_html/wp-content/blogs.dir/3/files/2010/06

    when I visit the site, images don’t show up and the generated path is http://pauldewouters.com/files/2010/06/image.jpg

  13. […] Pour m’aider, j’ai choisi d’utiliser ce très bon tutoriel, suivez le sans craintes, une fois terminé, passez au reste de la note : http://ottopress.com/2010/wordpress-3-0-multisite-domain-mapping-tutorial/ […]

  14. it is so strange after multisite being enabled, my main domain’s url posts are changed to be like this
    http://moblogger.co.cc/blog/2010/06/27/article

    yes! i got directory “blog” that unnaturally appear, how can I fix this?

  15. Thank you for your tutorial, I have done these steps but it doesn’t work. But I have a subdomain installation, can I change this to a subdirectory installation? My problem is that i can’t login to the wp admin menu when I map a domain. But when I use the blog without a second tld only with the subdomain the wp-admin login works. I hope someone can help me.

  16. I’ve tried this but its not working yet. To be honest I was expecting it to be easier.

    Why doesnt WordPress 3 MU support multiple domains out of the box?

    Does anyone know, if you do this will all your domains still be seen as separate by the search engines, with separate page rank etc?

  17. […] part of the tutorial is what I really gleamed from Otto’s post sited below and linked here: http://ottopress.com/2010/wordpress-3-0-multisite-domain-mapping-tutorial/. The domain mapping tool is what’s going to make sure that when someone hits one of your […]

  18. previously I’ve found this tutorial Multisite in another blog, but the tutorials on this blog is very complete. thanks.

  19. I have the plugin installed and working perfectly. One question: does it simply redirect to the primary URL + subfolder? Or is there a way to set it so that a sub-site can be viewed under the domain name that corresponds to it (with URLs intact)?

  20. […] Everything you wanted to know about creating a network of multiple sites in 3.0, WordPress 3.0: Multisite Domain Mapping Tutorial) var flattr_wp_ver = '0.9.11'; var flattr_uid = '5699'; var flattr_url = […]

  21. […] WordPress 3.0: Multisite Domain Mapping Tutorial » Otto on WordPress (tags: wordpress domain_mapping) […]

  22. […] WordPress 3.0: Multisite Domain Mapping Tutorial […]

  23. […] WordPress 3.0: Multisite Domain Mapping Tutorial » Otto on WordPress Guide to installing WordPress 3.0 MU with multiple domains (tags: wordpressmu wordpress tutorials plugin 3.0) […]

  24. Works Great! Thanks for the tutorial.

  25. […] contributor Otto has written a great guide about domain mapping in Multisite mode in WordPress […]

  26. Do you know how I can get this to work with a shared server?
    I’m using a shared cirtex hosting account at the mo and would really appreciate this info.

  27. Almost worked for me 🙂

    1) For WP 3.0 one should put

    – domain_mapping.php – to /wp-content/plugins/wordpress-mu-domain-mapping
    – sunrise.php – to /wp-content/

    2) define( ‘SUNRISE’, ‘on’ ); – br’s not needed (I did not take, but some users may be confused

    3) Under “Tools” no “Domain Names” appeared, but worked fine with “Administration” part, though not so visual 🙂

    And finally, thanks for great tutorial. Now there is less entropy in this world 🙂

    • No, you really need to put the domain mapping plugin into the mu-plugins directory. If you activate it in the normal plugins directory, then it won’t be active on all the domains, and it can be accidentally disabled, etc.. Things don’t work right, basically. Plugins in the mu-plugins directory are always forced to be activated on all the sites in the network.

      The instructions I gave above are correct. You should follow them.

  28. Wow, I’ve been searching for how to do this for a little while, this has worked fine for me on my first setup, thanks so much!

  29. Hi, this looks great, but I can’t seem to checkout the truck from svn…

    I get:

    [peterf@rack mu-plugins]$ sudo svn co http://plugins.svn.wordpress.org/wordpress-mu-domain-mapping/trunk domain-mapping
    svn: Valid UTF-8 data
    (hex: 63 6f)
    followed by invalid UTF-8 sequence
    (hex: a0 68 74 74)
    [peterf@rack mu-plugins]$

    and no download!

    It’s been a while since I used svn, so maybe I’m forgetting something, but this seems like a weird result! Invalid UTF-8 sequence???

    Thanks for the tutorial. I’m used to running many Plone sites on a single host port, and rewriting the URLs per domain (and with Squid Caching, etc), but haven’t done it with WordPress. Great to have multiple sites under one Admin in 3.0!

    Cheers
    Peter

  30. Hmmm. OK. Got it installed, and showing up in both super and regular admin screens…

    However, now when I try to access the blog under any domain (whether mapped or original) the (sub)site redirects to the /wp-admin/ screen.

    That is, I can’t get back to simply viewing the site.

    I’ve now removed the plug-in and the same thing continues!

    Any thoughts or pointers appreciated!

    Thanks
    Peter

  31. […] WordPress 3.0: Multisite Domain Mapping Tutorial. As an extension of the excellent walk through of the multisite functionality of WordPress 3.0 by our very own Klint Finley, Otto has put together a domain mapping tutorial that is receiving rave reviews. Follow the steps to map multiple domain blogs from within the same WordPress 3.0 install. VN:F [1.9.3_1094]please wait…Rating: 0.0/10 (0 votes cast)VN:F [1.9.3_1094]Rating: 0 (from 0 votes) Share and Enjoy: […]

  32. I followed your suggestions and after adding step 2 above to wp-config.php (and taking out the reference).

    I get this message for SuperAdmin –
    The domain mapping plugin only works if the site is installed in /. This is a limitation of how virtual servers work and is very difficult to work around.
    ??
    So do I need to recopy over files to a master folder and redirect files there??

  33. I can’t tell from the tutorial alone if I’m succeeding to the extent allowed or missing something basic.

    I can indeed cause additional domain names to be hosted on the same WP install using these instructions.

    But they all end up resolving to the subdirectory in the browser address bar.

    So a user can type addeddomain.ex and it will take them to the blog installation but in their browser bar it does not say addeddomain.ex, it says primarydomain.com/addeddomain.

    I can and have made this work with WP-Hive, but I’m concerned about falling out of the development loop for WordPress and feel pressed to adopt the new WP Multisite platform.

    So my question is: is the added domain supposed to end up displaying as a subdirectory of the primary domain? If not, then I have more work to do. But if so, it will save me a lot of grief is someone can let me know.

    tnx

  34. Otto, does this mean that yes, separate domains should appear in the browser address bar or no they shouldn’t?

    I did check before and the primary site was the primary domain. The secondary site showed as in the screenshots here and so appeared to be correct.

    The only thing that didn’t work as I expected was the fact that whilst loading the located at secondary.com in the address bar it displayed primary.com/secondary

    I have the site being reloaded from scratch right now. I’m going to start with MU 2.92 and “upgrade” to WP 3.0 as this has solved similar kinds of problems for me recently.

    • I don’t understand the question. What appears in the address bar is supposed to be the primary domain. Look at my own site here, you see ottopress.com in the address bar, not ottodestruct.com/op, which it actually is.

  35. From your answer it seems like you do understand my question and the answer is that no, the primarydomain.com/subdirectory (your example ottodestruct.com/op) should not be appearing in the address bar, but the added domain (your example ottopress.com)

    That being the case I have to go back to trying to understand where I’m making errors. It must be something to do with how I am setting up the domains in the CPanel of my host. With wp-hive I just had to point the domains at the same root. That didn’t work for me here. I tried pointing them at a subdirectory and that resulted in server 500 errors.

    I’ll keep at it — and I do appreciate you giving your time like this.

    • Yes, pointing them at the root is the correct way to do it. It’s how I set up new domains on my site here.

      Check all the various domain setting places. In the Super Admin->Mapping, in Tools->Domains, etc. See if anything looks wrong.

      Do you have any redirection plugins or something that might be interfering?

  36. No plugins at all. Completely fresh install. I’m going thru it very carefully again with another new install and let you know if I learn anything helpful.

    • I am having the same exact issue as wd_cwg

      when I go to example.com everything works as it should

      when I create a 2nd site at example.com/sub which maps to domain.com … then when I go to domain.com I see example.com/sub in the address bar

      fresh install, no plugins, using Godaddy host and domains

  37. I’ve found my issue and it’s incredibly stupid (of me).

    When dealing with multiple sites, I always interpret the phrase “primary domain” to mean the first or parent domain.

    So I interpreted the config checkbox “Primary Domain” on the Domain Mapping:Domains screen to be a question of “Is this the parent domain.”

    It does not mean this. It means, I think, do you want this new domain set up as a primary domain or a sub domain?

    All I do know is that by simply checking that box, the results are that I no longer get the sudirectory showing up in the browser address bar.

    I am absolutely embarrassed at the fact that I’ve spent days on this and not once did it occur to me to simply try checking that box. I go now, head hung in shame…

    • Ahh, yes, I see your confusion.

      With the domain mapping plugin, a given “blog” can have pretty much any number of URLs pointing to it. The “primary” domain is the one that is the main domain, and which shows up in the address bar. You can change which domain is primary at any time on the Tools->Domain Mapping area.

  38. Yhis is what got it working for me.

    Make sure the default Apache virtual host points at your WordPress MU site or WordPress 3.0 network so it will handle unknown domains correctly. On some hosts you may be required to get a dedicated IP address.

    As I have numerous other sites and frameworks served from Apache, I made my primary (dashboard) WP Vhost listen to a specific, distinct IP address and then DNS for each mapped WP domains points to that Vhost.

    • That’s one way to do it. There’s other ways as well. For example, on my Godaddy shared hosting account (what I run this site from), I just add the new domain then use their config screen to point it to the root of the site (the / directory). This apparently sets the necessary VHOST info on the server for me. Plus it works without a dedicated IP.

      If I had a dedicated IP already (like for setting up SSL or something), then I’d do it your way.

  39. Okay I got everything working now. Thanks for your post and comments Otto…

    I’m not sure why I have seen some people elsewhere say you need to install wordpress 3.0 multisite in your public_html or root (/) directory….. as I have successfully gotten it to work, with Godaddy and NOT having a dedicated IP address, on another folder sub directory off of my root directory

    In my case I just point all my new domains to the /wordpressmultisite/ directory and then it somehow all works

    • It doesn’t have to be in the file root, it has to be in the domain root. That is, you can’t have a subdirectory install in the URL.

      See, with GoDaddy’s configuration method and you and doing it like that, you’re actually setting where the URL root is. So your install is still a “root” install, though you used a subdirectory under public_html. You just redefined the URL root to be in that subdirectory.

  40. Im getting errors :
    Warning: include_once(/home/site/public_html/wp-content/sunrise.php) [function.include-once]: failed to open stream: No such file or directory in /home/site/public_html/wp-includes/ms-settings.php on line 22
    Warning: include_once() [function.include]: Failed opening ‘/home/site/public_html/wp-content/sunrise.php’ for inclusion (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/site/public_html/wp-includes/ms-settings.php on line 22

    I put all the files in mu-plugins folder like you said, i dont understand

  41. Ok, please pardon my ignorance..
    I am testing WordPress on my USB stick. I first had it located here xampp/htdocs/domain1/wordpress/
    It worked fine…
    I want to setup WordPress to test it for multiple domains I have. Have several domain subfolders in htdocs folder for each domain.
    If I can get it working fine on the USB stick then I’ll upload it to my web server.

    So I followed the suggestions on the other page and went into the database properties in phpmyadmin for the database I have and changed the location of wordpress to what I thought was the / folder the same as where xampp is located. No joy.
    I then figured that the wordpress folder had to be in the /htdocs subfolder of xampp to work so I moved it there and then changed the locations in my database.
    Now I get – “Error establishing database connection”

    I am confusing myself now.
    So where do I need to move WordPress to and what do I need to have the folder settings pointed to in my main database so that I can get access to SuperAdmin and add the other domains?

  42. […] Blog von Otto on WordPress im Artikel WordPress 3.0: Multisite Domain Mapping Tutorial fand ich eine recht detailierte Beschreibung darüber, wie das Domain Mapping PlugIn zu […]

  43. Ok, did that. Now get “Error establishing database connection” when accessing localhost. When trying to load a WP page it looks like php is not working. In xampp have apache, mysql started.

  44. I’ve create a multisite network with wordpress 3.0.
    All the subdomain work correctly.

    I should move my subdomain to other domain
    example1.domain.com —–> http://www.domain1.it
    example2.domain.com —–> http://www.domain2.it

    So create the wildcard for cpanel, parked my domains.
    and installed WordPress MU Domain Mapping for mapping the domain

    But it’s is impossible to login to the domains that I’ve created,
    I see the login page http://www.domain1.it/wp-admin/ , but when I type user and password nothing happen
    This is very strange because subdomain work correctly instead domain impossible to login it’s like a loop in login page

    Many thanks

  45. Hi,

    i have two domains (www.a.com, http://www.b.com) pointing right now to the same website. I want to divide the website in two (a & b) using same db, users, template, plugins, etc… – I have upgraded to the rel 3.0 of WP – and I want the two domains to point eachone one of the two websites.
    What are your suggestions?

  46. Thanks for this tutorial. I have been trying to upgrade to MultiSite. Everything worked fine until it got to the adding sites. It added it but the new added site, takes me to the 404 error page of the main domain itself.

    Also, where do I find my Server’s IP address?

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Need to post PHP code? Wrap it in [php] and [/php] tags.