Donncha’s Domain Mapping plugin

One often requested feature is the ability to put a domain name on a sub-blog. Most people are unsure of what to call it, so I’ll tell you – domain mapping. :) While there has been a few ways to approach this in the past, it’s now easier with Donncha’s WordPressMU Domain Mapping plugin. It also just had an update, so if you have been using it, upgrade it.

Installation is easy, with one extra step. Drop the plugin file into the mu-plugins folder, and sunrise.php into the wp-content folder. Open up wp-config.php (in the root folder) and find the line like this:

// define( ‘SUNRISE’, ‘on’ );

It’s pretty far down there. Take those two // away from the front so the command will run.

Since we placed the plugin in mu-plugins, we do not have to activate it. You’ll find the menu for it under Tools. If you haven’t done the above step with the config & sunrise files, you’ll get a helpful error message.

One thing I want to point out right here is that you need to do this *while in the backend of the blog you want to map*. This plugin was designed so that the user of the blog in question would do this, not always the admin. If you’re at the main blog and you go to map a domain, you’ll re-map the domain of the *main blog*. (ask me how I found this out. LOL)

Fill out the fields, click the button. That’s not all though. The domain itself needs to know where to go.

I usually handle this two ways:
- add an A record pointing to the IP of my WPMU install (works if the IP address also resolves to the WPMU install)
or
- park the domain on top of the WPMU domain (better on shared hosts)

You can park the domain first, and then set it up in the backend. The order of these steps don’t really matter.

Please note: this plugin currently only works with subdomain installs. If you have subfolder blogs, consider the Simple Multi Site plugin, which also adds more functionality.

[Post to Twitter] Tweet This Post 



Random Posts

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark
tabs-top  banner ad


60 Responses to “Donncha’s Domain Mapping plugin”

  1. Rodney says:

    I recently started using WordPressMU Domain Mapping plugin. It works great! One thing I noticed is that once redirected the plugin automatically removes the www (or sub domain).

  2. Andrea says:

    That’s kind of the point :)

    It takes subdomain.yourdomain.com and changes it to newdomain.com, while still being part of the same install.

    • Richard says:

      Hi – I am learning a lot from your site – thanks.

      I am setting up multipe sites on WPMU but want them to all display their full www. domain – but I can’t get them to resolve to the http://www.domain.com – instead they are defaulting to the non-www versions.

      If I put an entry in the htaccess file I just get a loop and it times out.

      Is there any way to set WPMU domain mapping to display http://www.domain.com instead of non-www ?

      Thanks

      • Richard says:

        OK I worked it out myself. I modified the actual plugin file to strip out the code which removes the www. This seems to work OK.

        • iain wright says:

          Richard,

          Would you mind sharing with me how you modified the plugin to allow for “www” addressses please?

          Also which file did you modify? It looks like the replacement happens in sunrise.php?

          Thanks in advance! :)

        • Sam says:

          Hey Richard, Which code (and where was it) that you were able to do this?

          • Richard says:

            Hi Sam/ Iain

            This space is getting a bit narrow! … I actually changed the domain-mapping.php file. Around line 303 I replaced …

            $domain = $this->db->escape( preg_replace( "/^www\./", "", $_POST[ 'domain' ] ) );

            with

            $domain = $_POST[ 'domain' ];

            Then similar changes in lines 430, 470 and 500.

            Please NOTE: a) I don’t know if there are any side effects of my changes as I don’ know the code well enough – but so far I have not found any – there probably are if you you wanted to host both www sites as well as wildcard sub-domains….and b) if there is a plugin update, it will obviously overwrite these changes so you would manually have to update the plugin whenever there is a change.

            Details of why I did the change are on my blog…

            http://www.searchgap.com/blog/hosting-multiple-domains-on-wordpress-mu/

            If you want the complete file just contact me through my website with your email address..
            Hope this helps.

          • Richard says:

            PLEASE NOTE: These changes relate to the incsub (wpmudev) domain mapping plugin which is based on Donncha’s domain mapping plugin and available in the premium members area of wpmudev. I originally thought they were one and the same. I guess a similar change should also work on Dnncha’s plugin. Sorry if any confusion.

      • andrea says:

        Was wondering what you guy were doing, as our domain mapping plugin (see tab up top) and Donncah’s (which Ron has also worked on) are both useable with WWW names without hacks.

  3. Joss Winn says:

    I’ve been trying to use this for a while now without success.

    I’d like to map blogs.library.lincoln.ac.uk/staff to librarystaff.blogs.lincoln.ac.uk

    Should this be possible? I’ve created a CNAME record to that effect, but it just redirects to the root address in my apache config which is learninglab.lincoln.ac.uk

    any comments appreciated. thanks.

  4. Jim says:

    @Joss

    Is that install using subdirectories?

    @Andrea

    We are using this plugin on UMW Blogs as well. I love it, but I find that after someone maps a domain we have issues with the login and uploads. I have to manually go into the blogs options in Site Admin and change the Domian table, siteurl table, home table, and upload url table for everything to work perfectly.

    Anyone else have the same issue? Or might this be a specific quirk of our setup? Inquiring minds would love to know.

  5. Joss – can’t do that with the domain mapping plugin. You should probably just add a redirect in the .htaccess file.

    Jim – try the latest version. It redirects the Dashboard to the new domain which unfortunately logs the person out, but avoids problems with uploaded files.

  6. Ben Gillam says:

    Hi everyone.

    Just trying to get my head around this.

    I have one blog on my domain and I want to start a second blog (different topic) but host in same space.

    Which lead me to wpmu

    I’m guessing I just a record http://www.domain.com and domain.com and get host to set up to accept domain to same space.

    Would then be possible to go to http://www.funys.net and get my mainblog and http://www.domain.com which will load what’s in http://www.funys.net/blog2
    If not is there a way I can do this? Thanks.

    • andrea says:

      If you’re only ever going to have two blogs, WPMU may be overkill.

      But essentially, yes – you set up the first blog on WPMU. Then within MU, you add the second blog, then map the domain to it. On the server side, you park domain two in the same spot as domain 1.

  7. Johan says:

    Hi Thanks. This sunrise.php is it an empty file I create?

  8. Johan says:

    Got it. I used the dashboard plugin install and was oblivious to the extra files like sunrise.php bundled with the download. Thanks

  9. Robin says:

    I’m using this plugin and it works great. The problem I’m having is one of our client’s LAN is set-up so that it needs the www on the domain in order to resolve. As a consequence, they can’t see their own company site on their lan. Is there a workaround for this where I can continue using the plugin for other sites but get this one to work? Someone mentioned .htaccess but I’m not sure what entry to make.

    Thanks,

    Robin.

  10. Yust says:

    Hi,
    Does it work on lighttpd? I’ve tried it but it doesnt work.
    Cheers

    ps.
    lol love your antispam word :D

  11. Tim A. says:

    This Domain Mapping tutorial has been very helpful. One thing, when you say:

    “add an A record pointing to the IP of my WPMU install (works if the IP address also resolves to the WPMU install)”

    If I want individual blog admins of my MU installation to be able to add domain mapping themselves once I’ve installed the plugin, how DO they “add an A record”?

    …If they’ve got their domain name registered with Dotster or Godaddy or whoever, are they able to add an A Record in their domain registration?

    Sorry for the confusion, can you please clarify?
    [rq=,,][/rq]

    • andrea says:

      Yep, they sure can do that. In Godaddy, they need to go to their domain management page, select their domain and then click “total DNS records”. We want them to leave the nameservers as is.

      In the Total DNS records area, they can add another record – which is where they type in your IP and choose the record type. (A).

      Pretty easy. :)

  12. Ron says:

    Yes, they add the A record at their domain registry or where their DNS is hosted.
    [rq=476,0,blog][/rq]Geek of the week

    • Tim A. says:

      (Re: Adding A Record)
      …OK, I see for GoDaddy how to add an A Record, and it appears that Dotster charges $10/year for “DNS Management” which I assume is how you do it with them. Not all registrars let you add a A Record apparently (?)

      If the domain name is hosted somewhere A Records can’t be added, there’s an alternate way of setting it up? …By having the blog user set DNS to the MU’s hosting company, and then adding that domain as a “parked” domain through CPanel by the MU main Admin?

      I’m sorry for the confusion, is the above correct? And is having CPanel the easiest way to accomplish the above, or it doesn’t really matter?
      [rq=,,][/rq]

  13. I just had the time of my life trying to figure out why this plugin would not work for me! And then, I tried a couple things…

    It was working and then stopped. So I went back to before and tried to see what may have caused the issue. I had recently installed a “upgrade” plugin provided at wpmudev.org and when I disabled that, it worked… for one of my sites anyway. When I reactivated it, the site still worked, so I am not sure if it just needed to clear something.

    However, I was having trouble getting another site to work with the mapping. I had it parked on the main install and added the domain to the plugin settings as I was supposed to. It would not work.

    So I went back into my cpanel to review the parked domains, and noticed the link for managing redirection. Just testing, I clicked the link and as suspected, nothing was there. However, I still clicked the “remove redirection” link and presto… the site now worked!

    So if you are having difficulty in getting this working, try those two items and see if they help you.

    On a side note, one of my concerns was with images and this plugin. I was concerned that when I enabled the plugin and mapped the domain that the images would pull from the wrong place. Good news… images come through with no problem. Anything uploaded prior to the mapping still have the subdomain as the URL, but it quickly pulls it using the right URL. And all the navigation links show up as the new domain instead of the subdomain in the page source, so SEO should not be affected.
    .-= Found By Design Websites´s last blog ..New Client: BA Eldridge Interiors =-.

  14. Brandon says:

    Donncha, thanks for the plugin; Andrea, thanks for the writeup.

    “If you’re at the main blog and you go to map a domain, you’ll re-map the domain of the *main blog*. (ask me how I found this out. LOL)”

    Er, I just did this [too]. Can you tell me how it might be undone?

  15. MyNursing says:

    Hey Andrea, I really enjoyed you and Ron’s site and advice. I don’t have all the saavy needed to try The Donncha plugin. I am going to use you guys’ Multi Site Plugin.
    .-= MyNursing´s last blog ..Welcome to MyNursing.org =-.

  16. mwaterous says:

    You mention that ‘This plugin was designed so that the user of the blog in question would do this, not always the admin.’ — I wonder if it wouldn’t be an idea for the future to change it so only the MU site admin can do it? I plan on adding this feature shortly, so I have no direct experience with it yet but I’m thinking it sounds a lot like it might be easy for an unassuming member to accidentally bugger up their domain mapping.

    Maybe I should actually install it before I rattle on though. :)

  17. marine says:

    I’m been fighting WordPress MU / Domain Mapping for a few hours now.

    I have
    1 Host
    1 Main website / blog
    3 additional websites (and more to come when I figure this problem out).

    Given each copy of WP is around 10mb I’d have to have to install it for each domain. To my understanding this plugin should let me map blog.additionalwebsite1.com, blog.additionalwebsite2.com, etc somehow. When I installed WPMU I did choose sub-domains but wondering if I should of chosen sub folders since my additional domain websites are technically in sub folders anyway.

    Any help would be appreciated. I could be created 25 to 50 blogs/domains a year, so a solution that will scale with this is what I’m trying to find. I thought I found it with WPMU, but I don’t want website40.blog.mainsite.com to be my address, I want blog.website40.com

  18. Jeremy says:

    Can anybody explain to me why the www get drops from the redirect and if there is a way to keep it?

    • Bronson says:

      I’m currently looking to put together a blog network for work and research purposes and this domain mapping stuff and multi-site are both interesting developments. Thanks for the updates.

      oh, Jack, if I’m stating the obvious, I apologise, but your problem sounds like either a permalinks issue or you have not set up cannonicaliztion (www vs. non-www) yet?

  19. Justin Smith says:

    LOL… I found your post because I did the same thing you did… I mapped the main blog accidentally.

    So, now my question is, how did you fix it? Did you have to do a re-install?

  20. Ron says:

    Andrea or anyone,

    Do you know is this the same plugin that Wordpress.com uses to map domains to their sub-blogs? Or do they have their own customized plugin?

    Also, will this allow you to map multiple domains to one sub-blog? ie. Orlando.com and CityOfOrlando.com

    Thanks,

    Ron

    • andrea says:

      It’s similar to their, but not exactly the same.

      This one is only for a single domain to a single blog.

      • Ron says:

        does the plugin that Wordpress.com uses exist in the public domain for other wordpress.org/wordpress mu users to install?

        I’m trying to install Donncha’s Domain Mapping plugin on my 2.8.4a version of WordPress MU and I am having difficulties.

        Is there a work around, or do I have to install 2.8.2 version of WordPress Mu?

        Thanks,

        Ronald

        • andrea says:

          This is the closet you’re going to get. Donncha works for wordpress.com.

          If you’re having difficulties, maybe I can help you with those.

          • Ron says:

            when I click on Tools: Domain Mapping I get the error: Sorry, domain mapping only works on virtual host installs.

            I have googled the error, and find lots of your postings, but either they apply to earlier versions, or I can’t seem to locate the “Manage Tab”.

            Any advice, my site install in on Hostmonster.

  21. andrea says:

    Right, this plugin only works if your blogs are in the format of subdomain.yoursite.com. If you have yoursite.com/blogname, then Donncha’s won’t work. Which is why you get that message.

    you’ll need one specifically to work with subfolder/subdirectory setups, like the one we have here:
    http://wpmututorials.com/simple-multi-site-plugin-e-book/

  22. Hey guys I have a MU install and went through all sorts of trouble just to get the sub-domains to work with Plesk… that is a whole other story, it works now, but when I try to remap the sub blog following the instructions nothing happens, I can’t even mess it up by remapping the main install, still nothing changes. Is there something natively in Plesk that makes this so complicated?

    I point the newdomain.com at the IP for my server, then I remap it in the backend of the subdomain.mydomain.com and nothing happens. I know the re-direct is working because the new domain now points at the Plesk generated place holder page on my server.

    Any ideas?

  23. Sorry about the double post, after I posted I had an epiphany and figured out how to fix it, I realized I needed to add an alias to the main install to make it work, not create a new domain in Plesk, but in the process I realized that a member would have to register their domain name, then redirect it to my IP then I would have to create an alias for it, and then they would have to map it. This is pretty inconvieneint for them, having to wait for me to create the alias, is there a better way to do this so that I am taken out of the essential process of remapping the domain? Or is this as good as it gets?

  24. Ron says:

    If you are on a VPS or dedicated server, poke around plesk and see if you can find an option where you can set your default host. If you find it, set it to the domain that has your wpmu install.

  25. Jorge says:

    Hi

    I just installed DM plugin. It’s working fine but just for the main page of the blog. If I click any of the links (posts, pages, feeds, etc) it doesnt work. Page not found. All the links are broken.

    Any idea on how to solve it?

    Thank you!

  26. I just want to document my mistakes and errors here, somewhere on the Internet, in case it saves someone else a trouble!

    I was making it *too complicated!*.

    I went into the blogs list, and for each blog, under Site Admin > Blogs, I changed the Domain setting so that it was mapped-domain.base-domain.com (as it should be), I changed it to just mapped-domain.com.

    This is confuuuusing, because it actually DOES WORK, in most ways. And, I thought I *had* to do it! Oops! When you do something that is wrong, in this case — there was no documentation to tell me NOT to do it! So, it took me a long time to figure out that that was going on.

    Also, to reinforce what Andrea means about setting the mapping in the particular blog you want it to map to:

    You must go into the back-end for that particular blog, and add the domain in the Tools > Domain Mapping panel for that blog. So, if you’re wanting to map my-mapped-domain-1.com, you’d actually be going to my-mapped-domain-1.my-base-domain.com/wp-admin/ (of course, you can use the Dashboard to navigate there), and THEN go to Tools > Domain Mapping, and under Add New Domain, add my-mapped-domain-1.com there.

    MORE THAN LIKELY, you will only map ONE DOMAIN per sub-blog. This is part of where confusion arose for me — I thought you mapped all of the blogs at a sort of “Top Level” admin area, and it figured out what domain went with what subdomain. This is part of why I thought I had to change the first part — I thought this would be how it would know. Oh, well. Don’t do that, do it this way!

    Chris

    • andrea says:

      With Donncha’s plugin, you have to do it from the backend of each blog.

      With ours (linked in the top menu) there is, in fact, one main admin area to map any domain from any blog.

  27. Minotauro says:

    Hello,

    I’m having some problems getting this plugin to work correctly.

    I’m trying to use this plugin on subdomain blogs.

    I create a blog (blog1.example.com)
    I map a domain to this blog (blog1.com)
    I set http://blog1.com as Primary Domain
    Go to Godaddy and add A record pointing the domain to the server IP address

    When I go to http://www.blog1.com I get the default godaddy parked page. When I go to blog1.example.com I ALSO get the godaddy parked page.

    From my understanding it was supposed to be the other way around. I thought going to http://www.blog1.com would show the contents of blog1.example.com. How do I accomplish this?

    Your help is appreciated. Thank you.

  28. Ryan Bickett says:

    I have installed the Domain Mapping plugin and am trying to set it up now for several of my blogs. One quick question, should I be setting the “primary domain” to be the one I want to have mapped to my wpmu subdomain site?

    mymapdomain.com (should I set this one as the primary domain?)

    …mapped to…

    subdomain1.wpmudomain.com

    Thanks,
    Ryan

  29. elif says:

    Hi,
    I’m reading all the documentation that i found but still confused. i created data.muhteviyat.com as a subdomain and i want to map with datamizindeyiz.com. i’m using direct admin page and several people also use the same ip that use. So, is shared hosting possible to use domain mapping plugin? I already point a record to my ip adress (bu exact the same ip adress that i use for my other domain which uses wpmu). but only thing that i see is welcome page of direct admin. Also if i make this domain primary, it doesnt work. any idea?

  30. Steve says:

    Ok, so everything works great, but I can’t log in to the sub domains now. Isn’t that kind of … retarded? Or maybe I’m doing something retarded here. Thanks in advance! Wonderful tutorial!

  31. Aithene says:

    Thanks! I couldn’t get it to work by posting to the mu-plugins folder, but it worked like a charm in the standard plugins folder. i just had to activate it.

  32. Sean says:

    I was going around in circles till I found you post. Nobody else seems to point out ->

    “…you need to do this *while in the backend of the blog you want to map*.”

    Cheers

  33. tylerr says:

    “park the domain on top of the WPMU domain (better on shared hosts)”

    What does this exactly mean? Could you clarify please? How can this be achieved on hosts WITHOUT Cpanel?

    Thanks a bunch!

    • andrea says:

      Make sure Apache takes all requests for the mapped domain and sends them to the folder you installed WPMU in. Set up an alias. ;)

  34. tylerr says:

    Thanks for the quick response.
    I think I got it. :)

  35. tylerr says:

    Very sorry for picking this up again… but just don’t know where to begin…

    Can we get an example configuration?

    Something like this:
    1. Server CNAME domain: example.com
    2. Domain panel: Add CNAME record…
    3. …

    I understand that to some this is a walk in the park, but what about the rest of us? :)

    Thanks a million!
    T.

  36. tylerr says:

    Thanks for all your help! I’ve managed to set it up… As you sad it was a matter of setting an alias. Sorry for “cluttering” your blog. ;)
    Cheers!

Leave a Reply