Mapping Multiple Domains into Single Instance of WordPress

Mapping Multiple Domains into Single Instance of WordPressI have come across a need of mapping multiple domains into single instance of WordPress installation for my blog myjeeva.com & myjeeva.mobi.  Then I did a search on the net, I found lot of references and plugins for single WordPress instance for multiple blog site within; take a look on top plugins for wordpress multisite but not for my need!

There are multiple ways to achieve mapping multiple domains into single wordpress installation (sharing everything except domain name).  I thought to create a blog post around these activities, perhaps it will benefit someone!

Note: Sharing same content across different domain might affect your SEO.


Approach Taken & Implemented

Below are the steps I followed for my blog.

  • Installed the WordPress into parent domain myjeeva.com
  • Configured various plugins for my blog
  • Pointed second domain myjeeva.mobi into parent domain IP through A record in DNS zone editor
  • Edited wp-config.php for two domain names according while accessing i.e. to reflect Site URL and  Site Home to respectively

Editing wp-config.php

  • Go to WordPress installed root directory and look for wp-config.php file
  • Place below lines after the table_prefix line; order is very important in wp-config.php , more info

  • Go to wordpress admin page and take a look at Settings -> General. You will have WordPress Address (URL) and Site Address (URL) will be in disabled state.  It means your wordpress installation dynamic enoungh to accomadate both domain address
Mapping Multiple Domains into Single Instance of WordPress

WordPress Admin -> Settings -> General

 

Completion

That’s it, now your WordPress instance have been enabled with multiple domain address.  I have shared the approach and step I followed for my blog. Make use of it!
  • http://www.awkreativ.com Adam Wadsworth

    Absolutely spot on dude, thanks for this snippet just used on a clients website, Saved me so much hassle figuring this out myself.

  • ismael

    Thank you very much, that’s what I was looking for!!

  • Brent Wallace

    Hi. I plan to try this, I hope it works. Are you limited to only TWO (2) domain names? Or could you use three or more? Thank you!

    • http://myjeeva.com/ Jeevanandam M.

      @Brent Wallace – It’s possible to map more than one name dynamically. It’s not limited to two.

      Cheers,
      Jeeva

  • KSuchdeve

    I was thinking about doing this, and saw this article as well. What are your thoughts on that? http://www.hostway.com/web-resources/search-engine-optimization/can-i-use-more-than-one-domain-with-my-web-site-for-seo/

  • http://myjeeva.com/ Jeevanandam M.

    It depends, for example serving similar content from different websites does affects SEO. Let’s you have more than one regional domain names for your websites with 301 redirects, will not affect SEO.

    Cheers,
    Jeeva

  • http://www.gainsanguns.com Raz M

    Thanks a lot :-) Exactly what I was looking for.

  • Will Lanni

    To clarify this: in your graphic above, you have http://www.myjeeva.com written into both the WordPress Address and the Site Address. Did you actually set this so that the .com is in the WordPress address and the .mobi is written into the Site Address?

    • http://myjeeva.com/ Jeevanandam M.

      @willlanni:disqus Once we use above code snippet from article. WordPress will automatically disables ‘entering URL from settings page’, since its become dynamic to accommodate .com and .mobi domains as described above.

      Cheers,
      Jeeva

      • Will Lanni

        Oooh got it. Yeah, I did notice that it was disabled, now I get what you wrote.

        So your database is set up initially using the primary domain (myjeeva.com)… and then it just picks them up from the DNS zone editor… ok. that makes sense to me now, hope my server admin understands that. Thanks for responding!

        • http://myjeeva.com/ Jeevanandam M.

          You’re welcome!

          Cheers,
          Jeeva

  • David Rose

    I can’t quite get this to work – probably made some minor mistake, but not sure what to look at.

    I originally installed and wrote my site http://www.hiretracknx.com – this all works correctly.

    As a test I then set up http://www.the-roses-at-home.com as described in your article.

    However the home page doesn’t load correctly (wrong fonts and links still refer to original site).

    Any sub page seems to work ok, so if I go to say http://www.the-roses-at-home.com/meet-the-team/ it all loads correctly and moving the mouse over any menu link again correctly shows the correct (the-roses-at-home) domain. It’s just when I go to the home page, all the links refer to the original domain and certain font’s don’t load at all (even though they load correctly on the other pages e.g social media Icons font)

    If any one has any suggestions as to why this might be happening I’d be grateful.

  • David Rose

    Ah, found my problem in an error “Font from origin ‘http://www.hiretracknx.com’ has been blocked from loading by Cross-Origin Resource Sharing policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://www.the-roses-at-home.com’ is therefore not allowed access.”

    Now to work out the solution.

  • David Rose

    all fixed, seems that the super-cache had an issue

    • http://myjeeva.com/ Jeevanandam M.

      @disqus_B9CcNve5uD:disqus – good to hear, its working!

  • Christoph

    Finally a solution which is simple and just works! Many thanks, this was exactly what I was looking for!

  • lis_locket

    Thanks for this – was very useful. I have a question which I hope you may be able to help with. I set my wordpress install within a directory called ‘site’. I pointed the 2 domains (for instance mysite.com and mysite02.com) I have to this directory and amended the wp-config file as you have stated. It all works fine for me – but another developer has told me that the url needs to be mysite.com/site and mysite02.com/site respectively as he is having errors with javascript. I didnt think this is necessary? Although the wordpress install is within a directory – as the domains are pointing to this directory is should all work? He has said i’ll need to move the whole install to the root.

    • http://myjeeva.com/ Jeevanandam M.

      @lis_locket:disqus I’m Sorry about delayed response, bit occupied with my day job.

      Your question has two scenario, let’s go one by one-

      1. If domain (for eg. mysite.com & mysite02.com) points to directory called ‘site’ then that is root directory for that particular domain. And you have wordpress install with that. It should work and there is no harm here.

      2. If you have domain (for eg. mysite.com), has two wordpress install under directory called ‘site01′ & ‘site02′. It is called subdirectory wordpress installation then URL has to be mysite.com/site01 and mysite.com/site02. So here domain root directory is different from wordpress site’s root directory.

      Typically it’s a choice of URL structure you wanted to deploy. Let me know, if you have any query.

      Cheers,
      Jeeva