Summary

I have come across a need of mapping multiple domain 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 ‘http://www.slideshare.net/AndreaRennick/top-plugins-for-wordpress-multisite‘, but not for my need!

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


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)
/*
 * Handle multi domain into single instance of wordpress installation
 */
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
  • Go to wordpress admin 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.
Wordpress Admin -> Settings -> General

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!
Tagged with →  
  • 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

  • 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

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

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

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