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

  1. Hi Otto!

    Do you know if it is possible to use the domain mapping plugin if the domain I’m mapping to is an ‘ADD ON’ domain, instead of ‘PARKED’?

    example:

    main domain: site.com
    site I want to map: photos.site.com
    I want to map it to: photos.com

    I was able to map it (photos.com works fine), but every link is still photos.site.com/*, e.g.: if you hover on a picture in photos.com, the link the user sees is photos.site.com/picture.jpg
    Also, the admin page is photos.site.com/wp-admin

    I believe this is because photos.com is an add-on domain in my hosting, not a parked one.

    I really wish I could use it like this, but with correct links.

    Do you know if this can be done?
    Thanks!

  2. Hello, I also wanna do the same thing as Guto G.

    Please give us some advices.

    Thank you.

  3. Hello there!

    I think everything gets fixed by going to “Sites” administration, “Edit” your site, and filling in the “Settings” tab the “Siteurl” and “Home” fields with your mapping domain.

    Following the “Guto G” example, you should:

    – Edit “photos.site.com” site
    – Click on “Settings” tab
    – Set “Siteurl” and “Home” fields with “http://photos.com” (no quotes, obviously)

    And make sure that in “Domain settings” (http://site.com/wp-admin/network/settings.php?page=dm_admin_page) you have disabled the option “Redirect administration pages to site’s original domain”. If not, you will be redirected to “photos.site.com/wp-admin” when you go to “photos.com/wp-admin”. And since you has changed the “Siteurl” and “Home” values to “photos.com”, you will not reach the admin pages when redirected to the subdomain “photos.site.com”.

    Hope it helps.

    BTW, Otto, I think this piece of explanation should be in any of your tutorials (here or in WordPress plugins) as you tend to think that doing all the mapping stuff will be enough for the images and everything taking the right URLs, and that’s not true.

    I even went to the hardest path (before guessing the easy previous one) adding this to the “domain_mapping.php” file…


    add_filter( 'upload_dir', 'domain_mapping_uploads_uri');

    function domain_mapping_uploads_uri( $dirs ) {
    $dirs['url'] = domain_mapping_themes_uri($dirs['url']);
    $dirs['baseurl'] = domain_mapping_themes_uri($dirs['baseurl']);
    return $dirs;
    }

    … in order to get the right URLs for the uploaded files.

    Thanks for reading.

  4. Hi,
    I’m using WordPress MultiSite with the insanenly helpful domain-mapping plugin. It works like a charm, but the login to the admin dashboard (both as a normal editor and as a global administrator) takes extremly long. It takes up to 3 minutes to login. I’ve tested it on Firefox and IE.

    Attached are my settings of the domain mapping plugin: http://113.imagebam.com/download/vi0oNV0femI7Gj0ru2bT-A/43696/436959264/domain-mapping-settings.jpg

    What can I do to solve the problem?

    Thanks in advance

  5. Hey Otto, I need your help!
    I am using WP for (website A). I just purchased a 2nd domain (website B) and am trying to create the site in WP, yet am having trouble. I try to ADD NEW under sites, yet WP automatically includes website A in the new site address link. :( How do I get around this?
    My 2nd domain is completely a separate site from website A. The domain name is websiteB.com

    This is my only option I have when creating a new site:

    Site Name: websiteA.org/ _______

    websiteA.org is NOT a part of the new domain, yet I can’t remove it or am given another option when creating the site name.

    How do I get around this?

  6. I tried the Domain Mapping plugin, but it did not work. So I installed WP again and created a new login, etc., though it wouldn’t let me use my websiteB.com domain b/c I already used it as a domain add-on. So I added a sub folder (websiteB.com/dir) & it worked. Then I had to go back into my 1st WP account & redirect the domain (website B) to the new link with the sub folder. Craziness! You’d think it would have been an easy solution. I wish I had never did the domain add-on to begin with & just installed & created a new log-on, etc, but that’s what my host & wp forums said to do. Two days of my life was spent figuring this out, but thankfully now I have two working websites!!

    I could delete them both & start over, but I don’t want to risk the site not working again & going through the hassle a second time.

  7. Mapping my two child sites worked great… thanks for the comprehensive directions!

    I would also like to look into mapping my primary (parent) site to a different domain as well. There does not appear to be a way to do that via the WP admin area. Ideally I’d like to simply map a new domain to the primary site rather than go through the steps of changing the primary domain in the database.

    Thanks!

  8. Hello,

    I have succesfully bound some domains to subsites in a multisite setting.

    Now I would like to use a domain wildcard. So I have http://www.domainname.com and domainname.com set to subdomain.hostingdomain.com

    I would like to add *.domainname.com to subdomain.hostingdomain.com

    I cannot do this with the plugin? Any example on how to do this with .htaccess?

    Regards
    Jurjen

  9. Hello:
    A quick background: I can configure C and A names in DNS, I have configured Virtual Host redirects, but I have never attempted the following and am stumped:
    Redirect a Domain name,
    .dns1.dns2.dns3

    to a WordPress multisite subdomain,
    .dns1.dns2.dns3/

    Please help!

    Thank you in advance for your assistance.

  10. Hello,

    I’m using wordpress 4.4 and subdomain multisite. But the domain mapping won’t work. It always says “Please uncomment the line define( ‘SUNRISE’, ‘on’ ); or add it to your /var/customers/webs/zenorm/wp-config.php”. But actually I’ve already put the define (‘sunrise’, ‘on’); in the config.

    Need help. Thank you in advance.

    Jeff

    • define (‘sunrise’, ‘on’); and define( ‘SUNRISE’, ‘on’ ); are two different things. Constant declaration is case sensitive, unless you specify the third parameter: define (‘sunrise’, ‘on’, true);

      this is from PHP Manual:

      bool define ( string $name , mixed $value [, bool $case_insensitive = false ] )

  11. I am still facing the issue. Do we still have to follow the same guide for WordPress 4.0+ versions. I am trying to do the same and create a subdomain like in http://10th.iresultsnic.in/. Can you please help me out?

  12. Hi otto,

    I’ve been meaning to install this plugin for a while and finally got round to it. I am using sub directories and when I visit example.com/newsite it redirects to the correct domain name, but doesn’t show the site. I created an “a record” for my mapped domain. Is this purely a hosting issue? If so what would I say to my hosting provider? May thanks

  13. Hi Otto, any help would be great, I have a rather convoluted problem and my hosts don’t support multisite (only found out after the fact):

    I have the following setup:
    Main Site ~ http://www.gemmazim.com (/home1/gemmazim/public_html/ (single WP install with the domain from justhost)

    Sub Site ~ http://www.touchafrica.biz (/home1/gemmazim/public_html/touchafrica/) (multisite with the domain from justhost)

    Sub Site ~ http://www.bushmanrock.co.zw (/home1/gemmazim/public_html/bushmanrock/) (multisite with a domain from a different host, but changed the name servers)

    I would like to be able to access the bushmanrock.co.zw site at that address but end up with the following in the address bar: http://gemmazim.com/bushmanrock/ and an error 404 page?
    When I tried using your plugin I get the message that it can only be used for a multisite installation from the root folder, I realise this is far from my current setup, but was hoping you had a couple of suggestions or workarounds that might help out?

    Many Thanks!

  14. “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.”

    wordpress probably changed since, because the only thing I’m getting in the domains menu is “search domains” and “add domains”, however there’s no way to find the id for a specific domain. it’s no longer posted under all sites nor on the page you specified

  15. hi.. I have installed the multisite successfully, and installed the domain mapping plugin.
    A very powerful plugin, thanks a lot.

    The subdomain works perfectly.

    However, as shown in this cropped image: http://awesomescreenshot.com/0f95mdl3a3, I don’t see where to add an domain as part of the multisite.
    I have set a domain parked.

    Let me put it this way,
    The current domain: good.com (multisite primary domain).
    The subdomains of good.com, e.g., sub01.good.com and sub02.good.com work extremely fine.

    The additionally parked domain: parking.com is not able to be added in the “Domain adding” like this: http://awesomescreenshot.com/0885mdm58a
    I can add the parking.com here, yet, it is NOT showing in the MySiteLIst of the Networks, and it only jump to the Primary domain: good.com.

    Is there anyone could help me out here, please?

    thanks.
    PS: 1). WordPress: Ver. 4.4.2. 2). Server: siteground GrowBig, 3). WordPress MU Domain Mapping: Version 0.5.5.1,

    • thank you.

      I have set the IP address, and deleting the Server CNAME domain.
      yet, I still see the additional domain jumps to the originally set primary domain. Therefore, the suggestion of the above setting is not working.

      Let me put it this way.
      The multisite domain: multisite.com
      The other domain that I hope to add: otherdomain.com

      I have parked the otherdomain.com at the same hosting server as the multisite.com, and pointing the otherdomain.com to the root folder of the multisite.com.

      Now, when I try to login the otherdomain.com/wp-admin/ , it just jump to multisite.com/wp-admin/

      It seems to me that the otherdomain.com is not working correctly.
      Could any one there help, please?
      Best regards,

  16. I have found the solution, ^^

    I am happy to share with people who might need.
    https://www.youtube.com/watch?v=IElX74ZFVvs
    This video shows exactly how to do it.
    There are 3 videos in this series.

    The 1st one shows how to install the Domain Mapping Plugin.
    The 2nd one shows how to create subdomain as part of the multisite.
    The 3rd one shows how to make a subdomain into the expected domain to be installed in the multisite.
    Enjoy it!

  17. I am still facing the problem. Do we still have to follow the same guide for WordPress 4.0+ versions? I already try one of my karnataka sslc blog named: http://karnatakasslcresult2016.in/. Please let me know how to fix it.

  18. Hi Otto,

    I keep getting this when I go to my mapped domain:

    Greetings Site Administrator! You are currently allowing “none” registrations. To change or disable registration go to your Options page.

    Not sure how to fix this.

    Also, how do i see all of my mapped domains? I do not have this super admin that you refer to.

    Thanks!

  19. Hi Otto,

    Have setup multisite and created my A records in my VPS.net Control Panel.
    I have also created a sub domain in cPanel: http://docs.example.com

    I have installed the MU Domain Mapping plugin and created a domain under the settings that points to http://docs.example.com

    The admin area of both the main site and “docs” sub domain work fine.

    My issue is that when I try and visit http://docs.example.com I simply get a white page with no content.
    If I disable the plugin, visiting the sub domain redirects to the main website http://www.example.com.

    Any help or advise would be greatly appreciated.
    Thanks

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

  21. Question please
    I am the Admin of all site in WordPress. I set domain mapping using the second method through the Admin of all the sites dashboard > Settings > Domains. I can see the map in Sites. However, when I use the new domain name that I just mapped to the old domain name it doesn’t work. Rather than get the site, I get a WordPress create your own site page. To fix this, I also completed the first method you mentioned for mapping, I logged into the site and in Tools>Domain I saved my new domain name as primary. Now the new domain name pulls up the site that my old domain name used to. So, it looks like this is a two step process and not one. I have to set new domain name in both places, but it seems setting the new domain name on the site itself has a higher authority than setting it via the Admin panel of ALL sites. Why? When I delete the map from the Admin panel of ALL the sites, I still can’t access the site cause it’s still mapped to the new domain name from inside the site under Tools>Domain.

    Is it a mandatory two step process? Or did I mess something up and really only need a one step process?

    Second, once I got the new domain name working, I am no longer able to access the site’s dashboard through the Admin Panel of ALL sites. How do I access the dashboard again once it got a new domain name?

    • I too am having an issue with not being able to access the dashboard/backend of the subsite once a new domain is mapped to it. Like HELPME, I activated the domain using Tools>Domain on the subsite rather than Admin >Settings > Domains. When I attempt to go to the subdomain’s dashboard, either through a link from admin or via newdomain.com/wp-admin, I get the login screen, but it doesn’t accept the login credentials of any user associated with the site, not even the Super Admin. What’s wrong and how do I fix it?

  22. Is there a fix for the instance when you haven’t correctly pointed the domain and as a result your site has ‘disappeared from the realm of mortal man’?!

  23. […] there’s one other part of this and that’s the Domain Mapping component. Otto has an excellent post on WordPress MU Domain Mapping, and covers it far better than I could. If you’re mapping custom domains to your WordPress […]

  24. […] there’s one other part of this and that’s the Domain Mapping component. Otto has an excellent post on WordPress MU Domain Mapping, and covers it far better than I could. If you’re mapping custom domains to your WordPress […]

  25. Hi, where should i install a single WordPress multisite instance in order to use the plugin?

    i receive the following message:

    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.

    Thanks

  26. “when you visit your new domain (before you do this!) then you want it to go to your main site, as is.”
    This is exactly what is happening, so I assume all of the configuration on that end is just right. But still the plugin won’t let me add the domain to the list. I might add it a hundred times, but it simply won’t go. The domain list is always empty. Any idea what might be the issue?
    Thank you!

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.