Domain Mapping Plugin - How can I map subdomains (www.domain.com)

Hey Guys,

I like the domain mapping plugin, but it is presenting a problem for me - I want to be able to map http://www.domain.com to one of my wpmu sites (ex: http://www.domain.com to timmah.wpmu.com)

the plugin instructions say to create an A record and for the TLD then a CNAME for the subdomain. Results in this pattern:
go to http://www.domain.com, I get redirected due to the CNAME and when I land on my wpmu site, I end up on domain.com.

I want to end up on http://www.domain.com.

Can the plugin support this? or is there a config option I'm missing.

  • wpcdn

    Hi,

    I think you're thinking there are a few more steps than there are. You wouldn't want to create an A and a CNAME. The instructions might not make it totally clear, but you want one or the other. To summarize:

    If your domain to be mapped is a subdomain (blog.domain.com), then you create a CNAME pointing it to the URL or hostname of your blog on the multisite setup.

    But, if your domain to be mapped is a top-level domain (domain.com), then you create an A record pointing it to the IP address listed in the domain mapping instructions. Then you add it in your multisite blog so WordPress knows what to do with incoming traffic to that domain.

    So you need to create an A record pointing domain.com to the A record of your multisite installation. Then, in the Domain Mapping settings in the Dashboard of timmah.wpmu.com, you add domain.com.

    Hope this helps.

    Mark

  • LexBlog

    Mark,

    I appreciate the insight, but I think my explanation was just too verbose.

    Went back through my settings and validated my issue.

    The domain mapping plugin wont allow me to keep 'www' in front of a domain. It changes the url from 'www.domain.com' to 'domain.com'.

    When I visit 'www.domain.com' it gets redirected to 'domain.com'

    When I try to add 'www.domain.com' as a mapped domain, the plugin automatically strips anything before 'domain.com'.

    This might cause me to go back to a different plugin.

  • wpcdn

    I see. There is a growing movement not to use the www any more (although some oppose this movement). WordPress multisite also doesn't use the www by default.

    One option is to map the domain without www, then at your source redirect the www version to the non-www version (which is then mapped to your WordPress installation).

    The plugin is actually doing the right thing, because it is designed to facilitate mapping a top-level domain (e.g., domain.com). Whereas http://www.domain.com is actually a subdomain. You might do a CNAME of http://www.domain.com to the blog URL, but the problem is that some systems like cPanel don't do well when you CNAME anything related to the top-level domain.

    Mark

  • Philip John

    Hiya Tim, Mark,

    The issue you have here Tim is that WP Multisite itself doesn't really support WWW.

    When you use WWW it's going to be looking for a sub-site called www rather than pointing to your main site as you are probably expecting.

    It's possible to achieve WWW I believe (though I wouldn't recommend it!) Here's how...

    1. Add your site in MS, then map the domain without WWW.
    2. Using mod_rewrite, add a rule to your htaccess for that domain that rewrites the non-www versions of the URLs to WWW versions.

    That *should* work but I'm not making any promises.

    Unfortunately I can't find any examples of exactly how to do this - they all just show how to redirect, rather than rewrite non-www to www.

    Phil

  • LexBlog

    Hi Phil,

    I actually solved this over the weekend by doing a little plugin hacking and editing the plugin:

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

    any preg_replace reference to www I removed, and now the plugin works exactly as I expect.

    I realize this isn't a supported config, so I wont be asking for help - but this would be a GREAT update to the next feature of the plugin.

    TD

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.