WordPress 3.0: Multisite Domain Mapping Tutorial

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.

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:

331 Comments

  1. Robert says:

    Great tutorial and very helpful. One point to note for those using IIS and multiple web sites as well as the WordPress MultiSites.
    The IIS website which hosts the WP Multisite Network will require an additional Host Header Record for each subdomain.

  2. Al says:

    hi I followed the instruction up to step then when go back to my login page I get this

    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.

    does any one have any Idea wats going on

  3. Mike says:

    Ok, I’m stuck on step 4.

    I’ve got a Hostgator Baby plan and my domains are at GoDaddy.

    I’ve got my domains Name Servers changed to my Hostgator account.

    I set up an addon domain from CPANEL.

    Do I redirect my mapped domain to maindomain.com or maindomain.com/mappeddomain/ ? It doesn’t seem to be working either way…

    • Otto says:

      You don’t “redirect” anything. You want your new domain to be pointing at the same hosting account (IP) and the hosting account to know the domain should be served from the same directory as your main domain (/ or /public_html or whatever the root of your domain is).

      In other words, make all the domains go to the exact same place: your WordPress installation. Let WordPress worry about what to serve to them.

  4. Paul DeVivo says:

    Everything seem to be working on my sites! But when I go to, for example discoverdarienga.com it comes up find, but the address it shows is discovergeorgiacoast.com/darien which is the folder instead of the discoverdarienga.com. I’m I missing something?

  5. John Suarez says:

    Hi, I followed everything said in here, but when I try and load the webpage I need mapped, I get this error message:

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, webmaster@tipboss.johnsuarez.net and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

    However, if I type in the subdirectory domain, it loads fine.

    Any idea how I can fix this?

    If it helps, I am using webhostingpad.com as hosting, and dynadot.com as my domain registry.

  6. Running into an odd bug. I’ve got main.com in a multi-site with domain mapping with a few subdomain sites under it mapped to their own domains. Everything seems to work fine except after about 10-15 minutes the main.com site goes down and displays a blank page, though the mapped subdomains still show up fine.

    If re-create domain-mapping.php, main.com comes back up but then goes back down 10-15 minutes later. Not seeing any errors in the log files, though the behavior seems like a DNS/vhost/cache issue?

  7. JD says:

    Great stuff, but having a major problem with domain mapping. I notice under your great tutorial you have the domain mapping under the tools, for me it comes under the super admin and does not allow me to add different domains only sub domains. Any ideas why this happens and how to fix this problem.Thanks, JD

  8. ivounnerry says:

    i followed the steps but neither domain mapping nor domains options showed up on neither Admin site menu nor tools menu.. when i checked the subdirectory site, the only thing that was added on my tools menu was the delete option.. where exactly should i put the define(‘SUNRISE’,'on’); on wp-config.php? also, do the mu-plugins and sunrise.php should be in the wp-content folder of the main public_html directory or should be placed into wp-content folder of www directory?? please help on this matter.. im working almost 2 hrs just to fix this prob but i really don’t know what to do next.. thank you in advance.

    • Asshu says:

      Underneath your other define tags .
      I mean to say that you have defined some other while installation .Do the same thing now.Just add the line just underneath them.

      Or I can make it Simple

      define( ‘SUNRISE’, ‘on’ );

      above the line

      /* That’s all, stop editing! Happy blogging. */

  9. Ricky says:

    I’m having the same problem as a few others here:

    I have mainsite.com setup as the root, and mainsite.com/newsite/ supposed to go to newsite.com

    But when i go to newsite.com, it redirects back to mainsite.com/newsite/

    I have both “Remote Login” and “Redirect administration pages…” domain options both unchecked. Any ideas?

  10. Ricky says:

    Thanks Otto,

    But now it’s doing a Redirect Loop.

    Wonder what i’ve got set wrong…

    • Otto says:

      You’ve probably setup the domain to redirect to the subfolder somehow. That’s not the right way to do it. Instead you need to setup the domain to simply point to your normal webhosting account, at the root folder.

      In other words, your domain needs to have an A record pointing to your web server, and your webserver needs to know to direct traffic for that domain to your root hosting account.

      All my domains are setup to point to exactly the same location. Same A record, same hosting account settings. The domain mapping plugin and WordPress takes care of what to display. You’re not wanting to make your domain redirect, you’re making it go to the site like it would go to a normal hosting site.

      Alternatively, if you’re using Firefox, it caches redirects. Clear the cache and restart the browser a couple of times.

      • Ricky says:

        Awesome, thanks for the help – i found out what the problem is and i’m sure others will have the same.

        With Cpanel, you need to add the domain as a Parked Domain – not an Addon Domain. Also make sure there’s no redirects like Otto advised.

  11. Ali says:

    Hi,

    We are actually facing a problem, once we follow the steps to install the domain mapping plugin it simply doesn’t load the dashboard. Starting from the ground up again is not an option for us as we just migrated to wp 3.0.1 and just cant understand the issue behind this.

    Any suggestions????

    Thanks…

  12. Mike says:

    What if I want the other domains to be spread out on different servers? I have an account at SEO Hosting where I have different sites on different IP addresses, but I want to manage them all from one site which is on a different server. For the secondary sites, I’ve set the DNS wildcard to redirect to the network IP address where the main site is located. I also set each site as the primary for their respective folders within the main admin panel. But it’s still showing the old site, and not reflecting the new one. Anyone know what to do in this situation?

    • Otto says:

      You can’t do that.

      The whole point of multisite is to run multiple sites from a single installation.

      If you’re running on multiple servers, you will need multiple installations, and they will not be connected to each other in any way.

  13. MadtownLems says:

    Hi! I’m using domain mapping plugin on a 3.0.1 multisite, and everything works great except for thumb.php generated images on mapped domains.

    Before mapping the domain, the img src looks like this and DOES work:
    http://multisite-root.com/sitename/wp-content/themes/theme-name/thumb.php?src=/blogs.dir/3/files/2010/08/Koala.jpg&w=100&h=100&zc=1&q=90

    After mapping the domain, the img src looks like this and does NOT work:
    http://mapped-domain.com/wp-content/themes/theme-name/thumb.php?src=files/2010/08/Koala.jpg&w=100&h=100&zc=1&q=90

    any ideas? Thanks!

  14. Tony Zeoli says:

    Hey Otto:

    We moved out site to root, but for some reason, the plugin won’t Activate. We’ve got sunshine in the right folder, we’ve added the code to htaccess and wp-config.

    Here’s a post on Codex I added today with the code: http://wordpress.org/support/topic/plugin-wordpress-mu-domain-mapping-plugin-wont-install?replies=1

    Any ideas why it won’t activate?

    Tony

  15. ivounnerry says:

    Got a problem here with domain mapping.. i want to map my subsite http://mydomain/site1 to http://anotherdomain.. i followed all the steps from editing the DNS Zone in WHM to creating a parked domain.. when i go to the site.. it only displays Server Error.. it’s like im not connected to the internet..

  16. Tony Zeoli says:

    Otto:

    Do you know what this means when you try and activate the plugin; Fatal error: Cannot redeclare dm_text_domain() (previously declared in /var/www/wp-content/mu-plugins/domain_mapping.php:29) in /var/www/wp-content/plugins/wordpress-mu-domain-mapping/domain_mapping.php on line 30

  17. Tony Zeoli says:

    Okay, so if I take domain_mapping.php out of the plugins folder and move it to mu-plugins, then the plugin disappears from the plugin page menu.

    Basically, I have domain_mapping.php in mu-plugins and sunrise.php in wp-content. I’m not seeing Domain Mapping in the Tools menu.

  18. Tony Zeoli says:

    Now I have this: Please edit your /var/www/wp-config.php and move the line define( ‘SUNRISE’, ‘on’ ); above the last require_once() in that file.

    Here’s my code:

    /**
    * For developers: WordPress debugging mode.
    *
    * Change this to true to enable the display of notices during development.
    * It is strongly recommended that plugin and theme developers use WP_DEBUG
    * in their development environments.
    */
    define(‘WP_DEBUG’, false);

    define(‘WP_ALLOW_MULTISITE’, true);

    define( ‘MULTISITE’, true );
    define( ‘SUBDOMAIN_INSTALL’, false );
    $base = ‘/’;
    define( ‘DOMAIN_CURRENT_SITE’, ‘dev.reesefelts.org’ );
    define( ‘PATH_CURRENT_SITE’, ‘/’ );
    define( ‘SITE_ID_CURRENT_SITE’, 1 );
    define( ‘BLOG_ID_CURRENT_SITE’, 1 );

    /* That’s all, stop editing! Happy blogging. */

    /** Absolute path to the WordPress directory. */
    if ( !defined(‘ABSPATH’) )
    define(‘ABSPATH’, dirname(__FILE__) . ‘/’);

    /** Sets up WordPress vars and included files. */
    define(‘SUNRISE’, ‘on’);
    require_once(ABSPATH . ‘wp-settings.php’);
    101,1 Bot

  19. Dan says:

    Everything works great except that the pages throw 404′s and the posts don’t show up listed on the front page unless you mark them “sticky”. The posts still show up listed in the normal widget that shows recent posts. I can still edit posts and pages. It seems to stay the same whether I turn on or off the W3 Total Cache or any other plugins. And this affects not only the mapped domains but the other domains seemed to start behaving this way, too. After I de-installed the domain mapping plugin and turned off the SUNRISE thing, the problem remained across the subdomains.

    There is one thing I do a little different from what’s standard, and that was I moved the .htaccess
    stuff into files “Included” by httpd.conf for performance and so I could just copy and modify things when adding another domain. But, it has worked perfectly without domain mapping and continues to work perfectly for the other WPMU installations I have on the same system using the same methodology. I tried looking at the wp_17_posts table and other numbers to see how some of the fields, such as guid look and compared them to some of the other sites. They seem to be normal as far as I can tell, though I’m not sure if they’re supposed to be relative to the subdomain or the domain the site is mapped to, or whether or how this is to be taken care of automatically.

    I wonder if anyone else has ever run into this. It’s probably something weird that I did. I’m
    on 3.0.1. If nobody has seen this, I’ll continue to dig through source code and see if I can find
    the root of the problem.

    Thanks,
    Dan

  20. Orlando says:

    Can someone help me every time I turn on the sunrise php in my config file I get this error “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.” what does this mean?

    • Dan says:

      Perhaps someone else can help verify whether what I’m saying is correct or not, but my understanding is when they’re talking about “root” or “/” in this situation, what they mean in terms of the Unix filesystem (or windows, too), it is the DocumentRoot. For example, if you have a virtual host on Apache that says the DocumentRoot for is /var/www/html/mysite, then your installation would need to be there and not in a subdirectory such as /var/www/html/mysite/wordpress. If you installed it there, you might be able to go back to your httpd.conf file or whatever you’re using for that vhost and set the DocumentRoot and the Directory entries appropriately so that /var/www/html/mysite/wordpress is now the DocumentRoot.

      In other words, it’s not telling you that you have to put your installation into the root filesystem of your system. That would be terrifying to most Unix system administrators to think about doing that :-) It would be for me :-)

      Dan

  21. Dan says:

    It can be n different places, but mine is in /etc/httpd/conf/httpd.conf.

    I ended up backing off from the domain mapping for now. I’ll stick to plain wpmu for blogs and drupal for packing several cms sites into one installation. Both are really excellent, but each one does some things better than the other. I’m finding really don’t want to be without either.

  22. Shush Arya says:

    Hi Otto,

    Great tutorial I have managed to setup the primary wp site with multi-site and domain mapping but now just need some help with mapping my first domain.

    My new domain is at godaddy and I have a vps hosting with mutliple ips. If I want to setup a mapped domain using a one of my available ip addresses how do I set that up at godaddy? I’m a little confused as to:

    1. How I assign the ip address from my hostgator vps account to the domain at godaddy
    2. What settings I need to change in the domain manager for the domain at godaddy to assign the ip and how I setup the dns. Do I need to setup a wildcard subdomain/virtual host record to the site’s DNS record in godaddy and how do I do that.

  23. Rob says:

    OK, Really stupid question: I’m at step 3. How do I find my server IP address?

    • Dan says:

      Ha…do I give the long, complicated, confusing, but correct answer and try to make it understandable later, or do I cut to the chance and give a few short things to try?

      How about pinging the server? Type “ping myserver.com” whatever myserver.com is.
      Or “nslookup myserver.com”
      Or “dig myserver.com”

      With nslookup you’ll get much more information.

      That is if your system is set up with a hostname and IP address known to the rest of the world in various DNS servers everywhere.

      If you’re logged into the machine, say on a console, you might be able to type
      “ifconfig -a” to get a listing of all the IP addresses your system is listening on.

      Your system may have an /etc/hosts file where you can see what the IP address is.
      You can type “whois myserver.com” to find out where the main, authoritative nameservers are for that hostname and all the administrative information on it, or if you’re not on a unix or linux system, you can browse to whois.com or go to godaddy.com, log in, and all in all, there are a zillion ways to find out what IP address or addresses a given hostname is mapped to.

      If you are getting hosting or getting a VPS from a company like ubiquity, they should provide that information for you in your emails from them. If not you can contact support, and then you can set up your own DNS to map your domain to that address with an “A” record, or in this case, if you’re using subdomains for wpmu, you may want to map your domain to that IP, then map * to that domain, and perhaps a servername you want to use to that domain. Then set up an MX record for where the email for that domain is to go. Godaddy.com has a TotalDNS you can use with their DNS servers and it works great keeping the DNS traffic close to the middle of the internet (that’s like saying middle of the universe, or halfway between minus and positive infinity).

      If you find your IP address is 127.0.0.1, that’s localhost. That’s for traffic between processes within the same computer and not for traffic on the internet. That would be wrong.

      If you find your IP address is something like 10. something or 192.168. something, then you’re working with an IP address that is not reachable from outside your local network unless your router is mapping incoming port 80 and/or 443 traffic directly to your server or through other network devices to your server somehow, but that gets into a whole-nuther sticky mess.

      Dan

      • Rob says:

        What is the easiest way to find it through cPanel?

        • Rob says:

          You guys really know how to turn the simplest thing into a project! All I needed was to know how to ping the sight from command prompt! Got it!

          • Dan says:

            At least the price is right :-) As for C-panel, I have a reseller’s account and the IP address shows under “Shared IP Address” on the left column about 2/3 of the way down. On one of the “sub” accounts, it doesn’t readily appear until I click on the “Stats” button and then it appears there, too.

            Dan

    • Mike says:

      Hey Rob, just go to http://whatismyipaddress.com/ and it displays your current ip

  24. Quentin Adt says:

    Hi Otto, great to read your blog.

    I have a main blog (A), from which I control the other domains. There are other blogs (B, C, ..) Everything is working well, excepted when new user registers to the blogs B, C.. : he receives an email with a link to the domain A, and when he try to login, they access to the dashboard of the blog A (instead of B), and can’t post an article.

    Another little issue:
    When I did a speed test (http://www.webpagetest.org), I saw the following call:
    http://BLOG-A.net/?dm=1ce9a77cb5987bce31a9dbe9823feed9&action=load&blogid=16&siteid=1&t=1177046446&back=http%3A%2F%2Fwww.BLOG-B.fr%2F

    That takes almost 1 second to be loaded.

    Do you mind to help me please ?
    Thanks !

  25. Robert says:

    Using MU Domain Mapping is it possible to actually support multiple domains rather than a re-direct. As we have installed MUDM at the moment it works… sort. What actually happens is that once a user has conected to the primary domain http://www.teamfans.com for example, they are re-directed to wp.multipledomainhost.com/teamfans for all subsequently served pages.

    What is required is that the primary mapped domain is to exist in it’s entirety so that all pages are served from that domain.

  26. Robert says:

    Now I figured it, it seems you need to set the Site Info (wp_blogs) Domain correctly to the mapped domain and Site Options (wp_siteid_options) Siteurl and Home correctly to the domain too. Then it works. I suspect that the upload directory needs changing too. None of these things occur automatically when you create a domain mapping. I have also found that the checkbox Update siteurl and home as well. seems to have unpredictable, or rather difficult to understand results.

    Robert

  27. Rob says:

    Hello Otto-

    Your tutorial was extremely helpful in getting my multisite up and running!

    I have one disappointment about privacy. My primary site is my business site and the secondary site is entirely personal, and supposed to be anonymous. However, when you watch the browser’s (firefox)path to the second site while it loads (in the address bar at the bottom), you can see it hit the primary site address just before the plugin maps it to the secondary site domain. Occasionally when the servers are busy you can see “waiting for primarysite.com” before it gets mapped.

    Is there any way to keep visitors to the secondary site from ever seeing the address of the primary site?

  28. Hi Otto -

    This is the best explanation I’ve found online (without a doubt!) and I should know because I’ve read just about every one of them by now. I’m so close now I can taste it, but for some reason I keep getting the “Sorry! This site is not currently available.” page from godaddy. I noticed you’re using godaddy, does this mean that I just need to be patient and wait for everything to get set up or did I do something wrong?

    Right now, I’m able to see all the same menus as you including all the super admin settings and even the Domain mapping option under tools when I log directly in to the wp-admin account for the secondary site I’m trying to create. I’ve set the Aname in my DNS settings to the Ip address for the original site and have the same number in place for the initial domain mapping settings. At this point, I’m at a loss. I don’t know why my chosen domain for the subdirectory site is not working. I even tried creating another multisite as a tester and set up the server settings for that domain to “park” ,as one of your readers suggested, and this time I only get the “coming soon” Godaddy page. Please somebody help.

    Thanks in advance!

    • Otto says:

      With GoDaddy hosting, there’s two steps on a new domain I use:

      1. Point the new domain to your hosting account. To do this, you use the DNS editor and put in your hosting server’s IP address for the main “@” record.

      2. Set up the domain on your hosting account. To do this, you go into the hosting control panel, find the “Domains” area, and add your new domain to point to “/” or the root of your web account.

      That’s all there is to it really. Usually takes about an hour to get working after that. If you do these steps *before* attempting to map the domain in WordPress, then when you visit your new domain, it will get redirected to your “main” domain. However, when that happens, you know it’s set up right and when you make changes in the domain mapping plugin, you’ll see the effects instantly.

    • Otto says:

      Here’s a couple of screen shot examples.

      DNS: http://ottopress.com/files/2010/09/godaddydns.png

      Domain Manager: http://ottopress.com/files/2010/09/godaddydomainman.png

      Pretty straightforward, really. I don’t know what “parking” does, but I’ve never done it.

      • Tony Zeoli says:

        Ott:

        I’m getting this:

        The constant “COOKIE_DOMAIN” is defined (probably in wp-config.php). Please remove or comment out that define() line.

        I don’t have that line in my config file.

        Tony

  29. Ah ha!! Thanks so much Otto. I was just missing step 2…

  30. Tony Zeoli says:

    Otto:

    We have a dev server and production server with two different IP’s.

    dev: 152.19.196.121
    production: 152.19.196.191

    I have input the dev IP into its admin and the production IP into its admin.

    But, I can only point the DNS for domain1.org and domain2.or to one IP, which is production (152.19.196.191). Is that correct?

    Because I’m not pointing the DNS entries to dev, my domains won’t work there. I can still each sites admin.

    What’s your workflow for rolling code from dev to production and testing domain mapping before rolling to production? I just need some help trying to figure that out.

    Tony

  31. Does anyone have an idea of how to set up the wordpress multisite so that each of nested sites has it’s own database? I imagine it’s got something to do with the WP-config file, but I’m not sure how to tell the browser to access the right settings and right database for each domain.

    Alternately, if you stick with the one database assigned to the super admin, does wordpress set up the various nested sites data in a way that will allow you to easily extract it later?

Leave a Reply

Your email address will not be published. Required fields are marked *

Connect with Facebook

*

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>