Categories
WordPress

WordPress MU Domain Mapping 0.5

WordPress MU Domain Mapping is a plugin that allows the users of a WordPress MU site to use custom domains on their blogs.

It’s been a while since the last release but with the help of Ron Rennick, and many others (kgraeme – you kick ass at finding bugs!) I think the wait has been worth it. Changes since the last release:

  1. Works in VHOST or folder based installs now.
  2. Remote login added.
  3. Admin backend redirects to mapped domain by default but can redirect to original blog url.
  4. Domain redirect can be 301 or 302.
  5. List multiple mapped domains on site admin blogs page if mapped
  6. Bug fixes: set blogid of the current site’s main blog in $currentsite
  7. Bug fixes: cache domain maps correctly, blogid, not blog_id in $wpdb.
  8. and lots more bugs fixed and squashed.

There are still a few limitations however:

  1. Your WordPress MU site should be installed in the root of your server.
  2. It’s not possible to map a path on the new domain.
  3. You cannot map a domain on to the main blog in a folder install of WordPress MU.

Grab it from the page above, make sure you read the readme.txt as the plugin needs to be installed and configured correctly. You’ll also need to be familiar with concepts such as CNAME and A DNS records and how to configure your server correctly.

Please try it first on a test server. We have gone to extraordinary lengths to try to fix every bug we could but it’s always better to be careful when trying out new software.

Comments

comments

By Donncha

Donncha Ó Caoimh is a software developer at Automattic and WordPress plugin developer. He posts photos at In Photos and can also be found on Google+ and Twitter.

117 replies on “WordPress MU Domain Mapping 0.5”

Hi Donncha,
Thanks for creating such a wonderful plugin. I have one question does it work well with your other kick ass plugin WP-Super-Cache?

It will work but unfortunately it won’t clear the cache when a new domain mapping is made so the old domain will show until the cache expires. Once that happens, the blog will redirect all the time.

I am having the same problem. Redirecting between the original subdomain back to the mapped domain only happens when logged in getting an Unknown key arror the follwing parameters are being passed:
?action=login&dm=1ba50ab52754c394be8d5f659ffda771k=84a8b1b13840bd30a9ac63e0b4403b91&t=1246379060

Was using version Version: 0.4.3 prior without problems.

I have a blog that started to give me a url of “http://mydomain.com/?dm_gotoadmin=1&back=%2Fwp-admin%2F”when I try to login to wp-admin, and reverts me back to the blog with that url. I have to remove the plugin in order to log in.

My other blogs are fine, so not sure what is going on with this one.

Thanks!

I’m having problems with the plugin.

The blog: pruebas.blogs.upv.es has a domain mapping: hen.cc.upv.es

When I access to http://hen.cc.upv.es the main pages is showed fine. However if you click on any of the test posts you get a 404 Not found. Same problem with categories, tags, archives, and the rest of the links.

If I remove the domain mapping and access to http://pruebas.blogs.upv.es all the post are shown right.

I found them via the codex, but that doesn’t seem to help. I can’t even get to the main blog. Everything is just an empty page. Is there something in the DB I can manually do to disable it from being used/called?

Donncha – problem resolved.

The problem was with the domain-mapping.php file. I mistakenly assumed that I could keep my backup version of that file (named domain-mapping.backup.php) within the same directory. Only to find out that whatever files are located within that directory will be loaded. So the old and new were both being loaded.

This caused me to go on a wild goose chase, because there were actually no errors logged. Hence the confusion.

At any rate, the new sunrise and domain-mapping files are in place and working as planned. Thanks again for the plugin.

Cheers,
–Jake

Blogs (Is that your real name? Really? Your parents were way ahead of their time if they gave you that name!) – anyway, you’ll just have to look through the plugin and adjust the code so it works the way you like it. There’s no simple “change this line …” solution here..

This is a great plugin but I’m having some problems getting it to work. I’ve got wordpress mu installed on the domain sambern.co.uk. I’ve set up a sub domain stefan.sambern.co.uk and I’ve used the domain mapping plugin to map the domain stefangeorgiou.co.uk to the subdomain stefan.sambern.co.uk. However it goes into a loop of redirecting to all three domains. Have you got any ideas?

Hi, I tried to run it wpmu domain mapping using nginx.
– wpmudomain.com is the main setup for wpmu
– I have another blog running at wpmudomain.com/anotherblogusingwpmu
– domain.com is a second domain and I’d like having a blog on it using wpmu

Problem:
When entering domain.com, it gets redirected to wpmudomain.com.
Any idea of what can be wrong?

domain.com.conf contains the following:
server {
listen 80;
server_name domain.com *.domain.com;

access_log /var/log/domain.com ;
error_log /var/log/domain.com_error;
location / {
root /var/www/wpmudomain.com;
index index.php;
if (!-e $request_filename) {
rewrite ^.+/?(/wp-.*) $1 last;
rewrite ^.+/?(/.*\.php)$ $1 last;
rewrite ^(.+)$ /index.php?q=$1 last;
}

}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/wpmudomain.com$fastcgi_script_name;
include fastcgi_params;
}

location ~ /\.ht {
deny all;
}
}

Thanks!

Hey Donncha,

First off thanks for all the fantastic work you do… I love WPMU and this domain mapping plugin… save me loads of time, energy, and space.

I’ve got one question though. When or how will we be able to use this on a WPMU install that’s not in the root directory of my web-server. I’ve got several WPMU installs that must be separate because they are Social sites that use Buddypress. Sadly, all but one of them must be in sub-folders on my web-server. So I can only use domain mapping on one WPMU install… that just makes me pouty inside… cause it’s such a great plugin.

Also, is this going to be a WP Core feature when you merge WP and WPMU or will it remain a plugin?

Richard – it’ll happen when it’s done, but honestly, you have all the same source code I have so there’s no reason you couldn’t code it or hire someone to do it. 🙂

Thanks Donncha,

I will actually be hiring a full-time worpress developer in a few months – so I may just have to add this to his list of projects. 😛

As for having the source code… I may have it… doesn’t mean I understand a bit of it. That’s why god blessed us with genius’ like yourself and hopefully any developer I end up hiring. 😀

Yeah, sorry for the short reply. I replied early in the morning when I was *too* tired. The biggest problem with the path AFAIR is swapping it in and out when redirecting from the domain mapped domain.

Donncha,

I’m having some trouble getting the plugin to work correctly…I’m running WPMU with Buddypress.

When I to go the dashboard of a subdomain and click on Tools-Domain Mapping, it redirects me to the primary domain’s dashboard.

If, from the primary dashboard, I click on Tools-Domain Mapping, it takes me to the domain mapping screen to add a new domain.

Shouldn’t the subdomains be directed to that same page but for their site?

Am I missing something?

Hi Donncha,

Many thanks for this, I will be testing it out to its fullest over the next few days on our dev server ( We also use the MU Multi-Site plugin – so will be keeping a watch out for any conflicts ).

One thing I can see without testing the plugin, is a lack of do_action hooks within the code… maybe I can help with this.

Basically, our own hosting makes use of an API on our datacenter where we can use simple xml calls to add/remove domain mappings to the apache configs plus a host of other unrelated things which means that when someone successfully adds/deletes a domain mapping in the wp-admin pages, we just hook in and tell apache about the changes.

Once again – thanks!

So that anyone reading can follow:
I have got around to testing the MU Domain Mapping Plugin (0.5) on my local dev server along side the Site Manager Plugin (0.0.9) on the current WPMU (2.8.6) and all seems to be working nicely together.

1st site: domain.tld
2nd site: another.tld
blog created: blog.another.tld
domain mapping: blog.another.tld = mydomain.tld

So far I can confirm it is working great – but not on our live system – so I suspect something else is causing redirect loops.
I will continue my testing after the holidays and let people know of my findings… also, I will be making a few minor modifications to include a few hooks and submitting them to Donncha ASAP…
I send everyone a good xmas/holiday/seasonal (delete as applicable) greeting and may the next year be a good one for everyone 🙂

It would be nice if it had a functionality to add a domain only if the domain responds to the server ip else say that ip is not redirected and not make the modification.
Thanks, great plugin.

hmm, i found a small bug:

If added domain with only english letters, and after I can’t add domain with hungarian alphabetical.
So:
I added this domain: janos.csardi.eu
And i can’t add this domain: jános.csárdi.eu, because Domain Mapping says this is an exist domain.

We had problems at first but after commenting out the define COOKIE_DOMAIN
#define(‘COOKIE_DOMAIN’, ‘.yourdomain.com’);

it worked fine.

I think the problem is with the
/wp-admin/admin-ajax.php which is going to http not https when the following is set define(‘FORCE_SSL_ADMIN’, true);
turning it false works fine.

Donncha — great plugin and thank you so much for all the work you do

I am having a pretty serious issue (for my site) with .5, however. It appears that it breaks any functions related to detecting if a user is logged in (on the domain mapped site).

E.G., on a domain mapped site I use the template tag which should display “Login” if the user isnt logged in, or “Logout” if they are. Regardless of how many times I log in, it never detects that the user is logged in for the domain mapped site — only the “original” blog (I am using the feature you added in bullet number 3).

That feature is awesome, by the way, because it allows us to purchase ONE *.blog.com SSL certificate, and all of our users can manage their content that way, but on the domain mapped site, it doesnt seem to be dececting credentials.

I commented before that the plugin only works if you select permalinks that use urls like ?page=number.

However, the uploaded files like images dont work cause they use permalinks with urls like /files/2009/…../

Any idea on how to solve this? I’m stuck 🙁

Thanks for your answer.

Is it possible to configure custom permalinks for uploaded files? How? I haven’t found any option

I’m confused. How is this plugin working for anybody then? I must have been misunderstanding something I guess.

Your domain-mapping-plugin version .51 is working for me.

It was very easy to install following your directions on the plugin page.

The enviornment:
– Ubunuty hardy 8.04 hosted @ rackspace cloud servers
– Apache 2.2 and PHP5 using a Vhost configuration
– WPMU version 2.9.1 mapping blogs to subdomains (example.domain.com)

URLS:
http://www.deskhead.com correctly maps to deskhead.diangysys.com
– diangysys.com is the main WPMU install

Donncha, is it possible for the domain http://www.deskhead.com to not change to deskhead.com in the browser address bar? I think perhaps its my DNS records changing things around? Or is this by design & necessary?

Thanks for the great plugin! Cheers —

Iain Wright

Donncha, i think i may be having a similar issue as Jorge. Whenever I preview a post on a mapped domain it cannot find my post. I am using custom permalinks for all of my posts, but the preview URL is still ‘?p=419’. Any idea how to get around this?

I’m having trouble getting the CNAME method to work; I end up at my server’s default “It Works!” page. I may be misunderstanding something in the readme, though. I’m not quite sure how to read these two statements:

If your user is mapping a hostname of a domain (sometimes called a “subdomain”) like http://www.example.com or blog.example.com it’s sufficient to create a CNAME record pointing at their blog url (NOT IP address).

and

Site admins can now choose to either allow users to setup DNS ANAME records by supplying an IP (or list of IP addresses) or set a CNAME but not both (entering a CNAME for the end user voids the use of IP’s)

so… does this mean the CNAME option can’t be used to map a top-level domain?

Thanks

You can use it, it’s probably a misconfiguration on your server if you’re getting the “It Works!” page. The virtual host for your MU site isn’t the first one perhaps.

Heh, yeah; it turns out I was just expecting too much magic. Wanting to host several non-WPMU services => no fully-general wildcard vhost => I have to set up vhost matching strings for each such mapped domain. At least, I set up my lighttpd WPMU config to load last with a “.*” host match regexp and it took over all the domains I was serving, including those not intended to be WP.

Donncha,
Thank you for the great plugin. At present, I’m running WPMU 2.9.2 with Domain Mapping .51 (testing with Firefox 3.6) — and I’m having an issue with the wp-admin login.

After searching/reading for 2 hours, I’ve not found an answer.

I noticed two people above (in your comments here) have had this same question, but it has not been answered. This was also an issue in the WPMU forums awhile back, but it appears to have gone away without much explanation as to how.

First, the issue.

On “mapped domains”, the wp-admin page redirects to the “dm_gotoadmin” page, which then returns to the default home page for that mapped domain (it does not go to the dashboard as one would hope). For example:

http://MySite.com/?dm_gotoadmin=1&back=%2Fwp-admin%2F

This happens if I enter http://MySite.com/wp-admin/ ..or.. if I use the “backend” from the administration dashboard of the main site.

I’ve cleared all cookies, verified all installation parameters (including wp-config.php notes) according to your instructions.

There are no php or httpd errors (I do have logging enabled). Everything else with domain mapping works perfect.

The only strange thing.. I notice there is a table in the database “wp_domain_mapping_Logins” and it is *empty*.

Should this have data? If so, how would I go about creating the data (either through the dashboard, or if you explain what I should enter for ‘t’ as the ‘user_id’ and ‘blog_id’ are self explanatory 😉

Thank you in advance!

I have a blog that started to give me a url of “http://mydomain.com/?dm_gotoadmin=1&back=%2Fwp-admin%2F”when I try to login to wp-admin

If i downgrade to v 0.43 it works just fine. Ifi use the 0.51 it doesnt work.

I get this on several domains

@R McKenzie: I will get to this bug when I have time but I’m surprised nobody has dived into the code of the plugin and attempted to debug it for themselves.

Using error_log() and wp_mail() to log events is fairly easy and the first thing I’d do is open up domain_mapping.php and look for the “gotoadmin” string and trace the code backwards.

Go on, scratch the itch and help!

@Donncha,
Thank you for the reply. Just the fact that you aren’t aware of the problem is enough for me to dig into the code. I’ve never coded PHP a day in my life, but I’m quite familiar with ASP and I’m sure I could make sense of it, if its not something you have time to do.

I’m just stuck with one problem — my install no longer has the error. Unable to fix the problem after hours of trying, I simply removed everything, installed WP 3.0 (beta, using Multi-Site Network) and re-installed everything from scratch. 0.51 is working fine in that instance, so I’ll have to create a new VM with 2.9.2 and 0.51 to begin testing.

One quick question, to get started. You mention — “Using error_log() and wp_mail() to log events is fairly easy” — is this something that is provided by WP, and if so, is there a developer’s guide to WP somewhere, where all of these sorts of details are provided?

If you’re referring to the wp_config file adjustment:

@ini_set('log_errors','On');
@ini_set('display_errors','Off');
@ini_set('error_log','/path/to/php_error.log');

I had placed this in my code originally, but wasn’t getting any errors (which I think I mentioned above in my post).

@R McKenzie: It’s one of those bugs that strikes sometimes, and it’s the hardest of all to fix. 🙁

You’ll need to do more to debug it though, adding error_log() statements to the domain_mapping.php file to track where the plugin goes and what it does. It’s laborious unfortunately.

@Donncha,
Thank you for the reply. Coming from you, as both the author and very experienced WP developer, perhaps this isn’t the best “first project” for me to delve into WP/PHP; particularly in consideration for not having an install where I can replicate this at present.

I was hoping this functionality would be intrinsic in the WP v3.0 “Multi-Site Network” feature; however, it doesn’t seem to be the case. I’m not sure why not, it seems to be a *very* fundamental component of MU/MS.

So if you’re having problems with gotoadmin not redirecting it’s more than likely because you’re not logged in.

I can’t replicate the problem on my test server but start debugging in the redirect_to_admin() function in domain_mapping.php, and look for “gotoadmin” and debug the functions that use that.

In that case, my guess is that there is an issue with reading the cookie on the user’s system, or in matching them to whatever you’re querying based on the cookie. Since in all cases, when I had the issue, I was logged-in / had logged-in, using valid credentials.

@R McKenzie: Yeah, you’re supposed to be logged in when you get to the gotoadmin url. That’s what makes it so hard to debug. Could be some browser settings perhaps. Did you change any security settings? Maybe cookies security settings?

Absolutely, positively not — no changes whatsoever (and if I had, I would have figured it out in the many *hours* of testing that I had done to try and get to the bottom of this).

I was using the same browser/workstation/configuration as was working find without domain-mapping enabled. Using the same configuration as I have now with v3 beta, that works just fine.

The problem is definitely not on the client side, I can assure you (based on hours of testing parallel WP setups). You may want to read up to my longer post above, for a quick overview, as well.

Oh well, just trying to exclude all possibilities.

error_log is a standard php command, and wp_mail() has the same parameters as the mail() commands. Use Google to find the php manual entries for them.

Donncha, the problem existed only on the “mapped” domains (not the original site, which was accessible without a mapped domain). Is this the type of answer you were looking for, or did I misunderstand?

@R McKenzie: No, that’s it. I still can’t replicate the problem myself. It’s bizarre.

On your new install do you have the “Redirect administration pages to original blog’s domain” option checked on the domain mapping site admin page?

The gotoadmin url is generated when that’s unchecked.

Hi Donncha,
Under “Super Admin > Domain Mapping” I have two options.

CHECKED > Permanent redirect. (better for your blogger’s pagerank)
UN-CHECKED > Redirect administration pages to original blog’s domain

If I remember correctly, I tested both options under .51, without luck.

If we could get one of the above users to respond (or you could go into the WPMU forums), we could get someone who has the problem currently, and try running with a simple debug output rather than redirect, perhaps that would save you some time?

I’ll look for a backup as well, and try loading that onto a VM.

Leave a Reply to Lazy Cancel reply