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,106 Comments

  1. Hi Otto,

    I’m wondering why this way works :

    I create a new wordpress installation inside foo.com, and add another site such as alice.foo.com, bob.foo.com, etc. It works perfectly fine.

    I buy another domain, named bar.com which redirects to my wordpress installation path to foo.com. So everytime I go to bar.com, I can be pointed to the foo.com. Here is the magic goes… I DON’T use the plugin you mentioned,

    0. I add another site inside foo.com/wp-admin/network/site-new.php. I named it bar.foo.com. Then I go to foo.com/wp-admin/network/sites.php, change the domain name from bar.foo.com to bar.com (it also changes the siteurl value to http bar.com)

    1. I go to my phpMyAdmin, add another row inside wp_site table, So I have 2 rows inside wp_site table
    id : 1
    domain : foo.com
    path : /

    id : 2
    domain : bar.com
    path : /

    2. I go to the other table named wp_blogs. And change the row that relates with the bar.com site. For example, it has id = 7 (because I have 6 sites inside foo.com, from 1 to 6). So, the id 7 has site_id = 2 (which relates to bar.com). Here is the complete rows

    blog_id site_id domain path
    1 1 foo.com /
    2 1 alice.foo.com /
    3 1 bob.foo.com /
    4 1 charlie.foo.com /
    5 1 dean.foo.com /
    6 1 eric.foo.com /
    7 2 bar.com /

    I don’t know if this works for others.

    • That’s what’s known as multi-network. You have created a separate network of sites using a different domain name. You haven’t put two separate domain names into the same multi-site network.

      A normal multi-site install is a single “network” of related sites. By creating a new row in wp_site and referencing it in wp_blogs, you’ve created a second, separate, network. The “site-options” and similar whole-site settings will be specific to individual networks.

      Note: WordPress has no user-friendly way to create or manage multiple networks of sites. It can do it internally, but it’s generally been deemed too confusing to put into the interface so-far.

    • Hi sangprabo,

      You are great you solve my problem.. Thank you very much indeed. Even I didn’t install any plug-in.. You’re manual setting working well. Now mutliple domain with multisite working absolutely fine.. Again thanks to share your experience..

  2. Hi otto, what should i use if i want to have two domain names pointing to the same WP content? During navigation i would want the domain name to stay the same, not to redirect to a primary site. So what i want is a sort of dynamic site_url, is that possible and advisable regarding SEO?

  3. how to define in cname section? ( http://i0.wp.com/ottopress.com/files/2010/06/domainmapping3.png?zoom=2&resize=607%2C431)
    we will enter the domain name of main domain like maindomain.com ???
    please help because i tried but it not work, setup this plugin with nginx and php-5 fpm ( not apache )

  4. Thanx a lot, this save me many time

  5. Hi Otto,

    I currently host a number of domain names on my 1&1 web server. I have installed WordPress multisite along with the Domain Mapping plug-in.

    How do I map domains on my server to the multisite.

    rather than being sitename.com/site1 I want domainname.com

    Many thanks in advance.

  6. I have a multisite install on a managed dedicated server – and i have installed the plug in properly but the domain can’t be found on the server it bonks to the plesk message no domain at this server. Does this have to do with the CNAME? I only pointed the DNS at the IP address… I would have thought it would go to the total-online.com if nothing else – the domain is total-phillies.com or total-rangers.com… need some help…

  7. Currently looking at redoing a WP site that had a developer plug in so we could have different titles depending on what section of the site you are on.

    But now I am looking at splitting up the sections so they are all different sites.
    But we would want the posts to be linked..

    Parentdomain.com (all the posts no matter what site)
    domain1.com (just posts just related to this section)
    domain2.com (just posts for this section)

    I would only want to put up the post once and tick/mark what section I want it to be on.

    We do have it in a form at the moment but it was done by a developer which as moved on and if we upgrade wordpress it will break.

    Any ideas

  8. Thanks for the post. This post became old, I think it should be upgraded. There are some additional options in MU Mapping plugin which are not mentioned here.

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

  10. Hi!

    Thanks for this tutorial, I did this BUT when I set the domain mapping to “Primary”, my site doesnt work :(

    My settings:

    I have a server with a domain name http://www.ahojkomarno.sk/spravy …… i want to map this address to http://www.sziakomarom.sk.

    But my “sziakomarom.sk” site has a automatic redirection to “www.ahojkomarno.sk/spravy”.

    I dont know why dont work..please help me :) Thank you guys :)

  11. Hello, I’m studying this configuration.

    I’m going to do a blog network with wordpress multisite and the plugin “WordPress MU Domain Mapping” to get all the main.com blog / site on site.com. I have some questions.

    - To do this configuration, you need a multi-domain hosting plan?

    - Or just a plan that does not support multi-domain?

    - If I should take from one provider to all top-level domains without hosting plan configuring the DNS. And then you took another provider with the main domain hosting space (does not support multi-domain). The configuration work?

    - With the “WordPress MU Domain Mapping” in the address bar will appear main.com / or site.com site? And in the paths of the images?

    Thank you very much!
    - Alessandro from Italy :)

  12. Hello, I’m using this plugin more than 1,5 years.
    But (I think) a few weeks a go, I got this message in my network admin surface:

    What is this?

    Plugin could not be activated because it triggered a fatal error.
    Fatal error: Cannot redeclare dm_text_domain() (previously declared in /home/softelit/public_html/wp-content/mu-plugins/domain_mapping.php:29) in /home/softelit/public_html/wp-content/plugins/wordpress-mu-domain-mapping/domain_mapping.php on line 30

    Please, help me … :-o

    Regards: John

  13. I just tried to setup a multidomain site, but the plugin looks totally different and do not let me add domains ?

    http://imgur.com/a/57N5p

    What am I missing, please ?

  14. Is it a good practice to place that plugin in the mu-plugins directory?

    What will happen if updates are released for the plugin?

  15. Hi Otto,

    Thanks for the gr8 plugin, you save my time, but still confused some where

    I am planing to start few sites in WordPress, I want to use the same “DATA” in all the websites like Post, Pages and Plugins, but only need different THEME and Menu on each websites.

    How it can be possible in my case.

    Before checking your plugin I was planing to install new wordpress on each website then import all the data from the main site,

    Thanks a Million for this gr8 plugin.

  16. This tutorial save my time. Thanks Otto!

  17. […] 3.0 – WordPress 3.0: The 5 Most Important New Features – Working With MultiSite In WordPress 3.0 – WordPress 3.0: Multisite Domain Mapping Tutorial – Upgrading from WPMU to WP 3.0 – Everything about WordPress 3.0 Menu Management – Goodbye, […]

  18. Hi Otto

    Can this plugin be used when my wordpress domain is using cloudflare’s DNS?

    Thanks,
    Joe

    • I don’t know much about Cloudflare’s DNS system, but probably. The trick isn’t configuring DNS, usually, the trick is configuring your webserver properly.

      Several things have to happen to do domain mapping like this:
      - The DNS has to be configured to point the domain at the IP of your host.
      - The host web server has to be configured to have those domains mapped to the WordPress installation.

      This plugin then takes over after that, and maps the domain to the individual blog in your multisite installation.

      • Thanks for responding.

        Is it possible to setup a CNAME record at the domain registrar to point to an A record at cloudflare? I know I could just add an A record at the registrar to point to the IP address of the server that wordpress is hosted on, but then the traffic bypasses cloudflare

        • No, because you cannot use a CNAME for a root (naked) domain. CNAMEs are only for defining subdomains. Root domains have to point to Address records.

          Technically, the reason you cannot have a CNAME for the root domain is because, per the RFCs, a CNAME record cannot co-exist with any other records for the same item. Since the root domain must always have NS entries for it, it cannot also have a CNAME. While there is nothing actually stopping you from putting a CNAME record there, the bottom line is that no DNS system supports it and it just won’t work.

          If you’re going to use Cloudflare DNS like this, you kinda have to use it for all the domains, or to have that domain not pointed to Cloudflare at all and instead just going direct to your actual server hosting that domain.

          • The easiest way to do that is simply create an A-Record using CloudFlare’s DNS in which you have just the root for that domain pointing to the correct IP address. It goes without saying, of course, you must have your PTR records at your registrar pointing to the correct CloudFlare DNS servers.

            By the way, in case you didn’t know it, CloudFlare has the fastest DNS on the planet and it is consistently the fastest to propagate.

  19. […] to use one low-cost shared hosting package to run several small sites.  There are already several nice tutorials about achieving this, but most were written for earlier versions of WordPress and talk […]

  20. Hello, thanks for this great tutorial!

    I installed my first multisite blog and it works fine.
    I installed the dub-directory version:

    MainSite => blog.domain.de
    http://www.domain2.de => blog.domain.de/domain2
    http://www.domain3.de => blog.domain.de/domain3

    and this works.
    now i have a domain where i only can use a subdirectory:
    http://www.domain4.de/blog
    so i wanted to map it:
    http://www.domain4.de/blog => blog.domain.de/domain4
    but this doesnt work.
    If i call http://www.domain3.de/blog i would be redirected to blog.domain.de

    perhaps i have to change my .htaccess or is it not possible to map domains+subdirs like i want?

    my .htacesss:

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]

    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    # END WordPress

  21. […] Full instructions are on the Installation page and are quite easy to follow. You should also read this page […]

  22. […] server settings. A great tutorial for setting up this plugin can be found on Otto’s blog, “WordPress 3.0 Multisite Domain Mapping Tutorial“. Full […]

  23. I followed your instructions up until step 3 where you say…

    ‘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.’

    I can’t find the admin page even though I’m logged in as a super admin. I’ve installed the plugin package and moved the required files?? Thanks in advance.

    • On the Network page, look under Settings->Domain Mapping.

      • Seems I’m in over my head. Now I’m stuck at step four. I’m using WP 3.8.1 so the images you have vary from the newer version.

        I’m actually installing domain mapping to overcome another problem I’m having on my newly created multisite. The real problem I’m having is that when i try and create a sub-domain of my site sub.mysite.com.au it won’t let me in to the admin page.

        Any advice greatly appreciated.

        • I did write this 4 years ago. Things change. :)

          The basic steps are the same, but the screens are different. There isn’t much more to it than what is in these steps. You set it up, give it the domain names, assign them to sites, and that’s pretty much it. I’m still using the plugin on this site too.

          This plugin isn’t going to solve any problems for you, really. I deliberately didn’t include any of the things you have to do to setup your DNS for wildcards, or how to configure Apache or nginx for wildcard subdomains. Those are where you’ll have the actual problems. All this plugin does is to map incoming browser requests to sites in the multisite instance by the domain name. It doesn’t do the whole job.

          • No probs, thanks for replying. I kind of got what the plugin does and wondered if it would help at all but figured it was worth installing anyway, I just can’t find some of the bit that maps my domain.

            Not to worry, I’ll have to give it a rest for the night and try again tomorrow.

            Thanks again

  24. I installed multisite primarily because I bought a new domain name and want to point it to my existing WP installation. I cant’ just forward the domain because of the database issues.

    I’m wondering how do i setup a site without installing a new WP blog? I want to simply point the new domain name to the main site. How do i set this up from the ‘new site’ screen?

    Also, does the new site need to be in a subfolder of the main site folder or can it be in a different add-on domain folder that exists equal in hierarchy as the main site folder?

  25. Follow up to my previous question

    Since my purpose is to map a new domain name to my existing MAIN site, I tried using the ‘/’ setting for the folder location of my new sub/child site. When I previewed it, it did go to my main WP site.
    This is what I want, but I wonder if by doing this, it may cause a problem. Also, if this is ok, I presume this mean i should continue using the dashboard of the MAIN site.

  26. Hi Otto

    Thanks for the nice pulgin. i tried few times and failed, could not succeed.

    May be my understanding is wrong, so i would like to confirm you or somebody.

    Here is the thing, which i want to achive.

    I have domains, in 1&1 ex: http://www.maindomain.com
    hosting account with Godaddy : Added http://www.maindomain.com and installed wordpress, everything works fine.

    Now I got new domains at 1&1, http://www.newdomain.com, http://www.newdomain2.com.

    These two new domains, i want to fetch the contect from maindomain.com

    ex: http://www.maindomain.com/category/post.html
    http://www.newdomain1.com/category/post.html
    http://www.newdomain2.com/category/post.html

    all should get the contect from same database.

    How do i achieve this, please help me out.

    Thank U :-)
    Sreeker.

  27. its like three domains, acting as different websites, but fetching the content from same database.

    I tried by creating sub.maindomain.com, but failed again.

    what i did was, created sub.maindomain.com at 1&1. configured in godaddy and installed wordpress, this works fine.

    2. now Enabled http://www.maindomain.com (network sites)
    3. edited wp-config.php and .htaccess files
    4. Logged in again, then installed pulgin and activated -logged off.
    5. Moved file sunrise.php to wp-content.
    6. logged IN again network admin
    5. Added sub.maindomain.com site to Networksites menu.
    6. added Godaddy Hosting IP address.
    7. tried to domain mapping, but there is no domain folder to add.

    there i’m stuck again.

    Please help me out. waiting for your reply.

    5.

  28. Hi,

    After I have configured the plugin and mapped to my domain, I got this message when I acess my site:
    Internal Server Error

    UID of script “/home/httpd/html/index.php” is smaller than min_uid

    suPHP 0.6.3

    Please, help.

  29. I’ve got a WordPress multi-site installation configured to do subdirectory sites. Using this domain mapping plugin, I’ve successfully got several domain names transparently mapping to sub-sites, so people visiting AAAAA.com and BBBBB.com actually see content from mysite.com/AAAAA and mysite.com/BBBBB. I’ve done this with an ‘A’ record pointing at the IP of my WordPress installation.

    I’m having trouble though setting up mapping of a subdomain blog.CCCCC.com to mysite.com/CCCCC. I’ve added a CNAME record for ‘blog’ pointing to mysite.com, so that visiting blog.CCCCC.com shows me the root site at mysite.com/ but I can’t get WordPress to show the content from /CCCCC instead of just /. I’ve added both “CCCCC.com” and “blog.CCCCC.com” as new domains with the domain mapping tool, but it doesn’t seem to make any difference.

    One thing I’ve noticed is that the site at CCCCC.com uses https all the time for everything, so the URL is actually https://blog.CCCCC.com/ rather than http://… — is that perhaps causing WP or the plugin to “miss” the mapping?

    Thanks in advance for helping.

  30. When using this plugin, is it possible to host multiple WordPress sites on both different domains and also subdomains? For example, if I want:

    site1.com
    – sub1.site1.com
    – sub2.site1.com
    site2.com

    all running off the same WordPress install. Your instructions here seem to indicate that it can only be used for different domains (e.g. the automatic prefixing of ‘www’ in the Add A New Domain form).

  31. Otto, first off… thank you for the tutorial, it really simplified things for me.

    On another note, at the very end of your tutorial, you wrote:
    *However, your main domain will always be accessible as long as you don’t try to map it*

    I really wish you had written this up in the Step 4 section when the tutorial was taking me through the process of mapping my domains. Plus your image graphic shows an example of you mapping your main domain. So naturally, I went ahead and mapped my main domain. But then when I got to the end of your tutorial, you cautioned against this, after I had already completed Step 4.

    Please, I need to know…
    - what problems will having my main domain mapped cause for me… is it really that bad?
    - are there any benefits to keeping my main domain mapped?
    - is unmapping my main domain possible? in other words, is mapping my main domain reversible?

    • No, ottopress.com is not my main domain. My main domain is ottodestruct.com, and ottopress.com is the domain that I mapped a subsite on that domain to.

      You cannot remap the main domain. It’s the one thing that you cannot change.

  32. Thank you soooo much Otto for the quick and helpful response! :-)

    Mapping my main domain caused me to lose Super Admin access. At first I panicked, but then found a nice workaround to undo my mistake. I simply logged into phpMyAdmin and changed the Active entries from 0 to 1 for the primary (i.e. ottopress.com), and from 1 to 0 for the main site (i.e. ottodestruct.com). This restored me to Super Admin access, thank goodness. Is this sql deletion/solution good enough, or just I just purge and then re-install the plugin for a fresh/clean copy so that I can avoid my mistake of mapping my main domain???

    Please please please help with just a few more questions:

    Lets say I want to use the CNAME method instead of the IP method. Assuming ottodestruct.com/op is where the blog/content is hosted, then I would follow these steps, correct???
    Step1. On the “Domain Mapping Configuration” Screen, in the “Server CNAME domain” field, I would enter in ottodestruct.com and click save, correct?
    Step2. Next, I would navigate to the ottopress.com domain’s DNS Manager Tool, and add a CNAME record where I save ottodestruct.com as the target destination for ottopress.com , correct?
    (pls note that my DNS Tool already indicates that there is a CNAME record setup for ottopress.com with the “www” prefix/sub-domain … should I just edit this record and change the target to ottodestruct.com , or should I create a new CNAME record and leave the sub-domain field blank but add in ottodestruct.com as the target)

    On the “Domain Mapping Configuration” Screen, WP Version 3.9.1 adds the following 5th Domain Option:
    **Disable primary domain check. Sites will not redirect to one domain name. May cause duplicate content issues.**
    Can you please explain what this 5th Option does? If I am making the blog/contents hosted at ottodestruct.com/op appear when visitors navigate to ottpress.com , then I would want to leave this box unchecked, correct?

  33. […] you need to copy a file, to modify some and to configure the mapping for the domains. A very good tutorial was made by Otto on using Domain Mapping plugin. Plugin site: […]

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=""> <strike> <strong>

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