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 &  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
  • Configured various plugins for my blog
  • Pointed second domain 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



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!
  • 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!

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


  • KSuchdeve

    I was thinking about doing this, and saw this article as well. What are your thoughts on that?

  • 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.


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

  • Will Lanni

    To clarify this: in your graphic above, you have 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?

    • @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.


      • 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 (… 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!

  • 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 – this all works correctly.

    As a test I then set up 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 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 ‘’ has been blocked from loading by Cross-Origin Resource Sharing policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘’ is therefore not allowed access.”

    Now to work out the solution.

  • David Rose

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

    • @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 and 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 and 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.

    • @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. & 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., has two wordpress install under directory called ‘site01′ & ‘site02′. It is called subdirectory wordpress installation then URL has to be and 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.


  • Rodrigo Azevedo


  • Greenline

    I am creating a small network using Post types. Each author is assigned to a post type and each author has an author page with their own posts. Can I with this code assign a different domain for each author page? I read that having multiple domains gives you negative google SEO point due to duplicate content…? Thanks!

    • @disqus_LYYYDV7yc2:disqus Yes, that’s true about SEO. However I believe as per your scenario it won’t cause any issue. Since each author will be having their own content. Good luck.


  • Juergen Tolksdorf

    Helped! Thanks for the article!

  • Ben Harris

    This is an incredibly simple solution to a complex problem, but keep in mind that with this configuration anyone can point a domain name at your IP.

    • Jiří Cerhan

      It’s actually not true. Yes anyone can point their domain A record on any ip, but it doesn’t mean the server will point it to a folder. It depends on your hosts (zones of whatever you call it) configuration.

  • I have configured my domain1 DNS to point domain2.

    I made the above change in my wp-config.php
    domain1 redirects to domain2 (with or without the change)

  • Twan Kouwenberg

    I just solved my problem through WPML


  • Jiří Cerhan

    Thanks, works just fine.

  • Jack Zahran

    Does this mean that each domain name (same IP Address) will point to a different site in a MultipleBlog installation of WordPress?

  • Yes, It will work. Just give it try at your end. Please have backup copy always.


  • Damian Sutton

    Fantastic article, this worked perfectly.

    But we have just been asked to convert our word press instance into a multi site.

    So I have updated the wp-config.php file with

    define(‘WP_ALLOW_MULTISITE’, true );

    And now, the domain keeps jumping back to the domain defined in the database, rather than using:

    define(‘WP_SITEURL’, ‘http://’ . $_SERVER[‘HTTP_HOST’]);
    define(‘WP_HOME’, ‘http://’ . $_SERVER[‘HTTP_HOST’]);

    Any ideas on how to make this work for a multisite setup?

    • Sebastian Krywult

      Did you figure it out? I’m facing the same problem.

  • still works, thanks!

  • Dario Locatelli

    very interesting article, thanks Jevaanandam, but it will work also for “sharing” hosting?


  • it’s work for me, thanks a lot

  • Luis Agudelo

    works very well! Very elegant solution to a very common issue. Thanks a lot!

  • This looks cool, Jeevanandam – about to try it. A Question: i need to display content based on the domain – I want to simply run a conditional if then switch based on the domain – is that a right way to do this, or would you suggest another way?

    Thanks for this, good stuff…

  • Here’s a trick I just learned while trying to add an A record at my host (GoDaddy – greatest tech support on the planet). I discovered that, as I’m using shared hosting, all my domains are on the same IP address, so I wasn’t able to point one domain to another IP address…

    BUT, if you have this same problem AND you’re using “add-on domains” to host multiple websites at your webhost, all you have to do is change the domain root – “public_html/domain” to point straight to the domain root you’re wanting it to point to, such as simply changing the folder path to the webroot = “public_html,” or I guess “public_html/other_domain”

    then the changes to your wp-config file that Jeevanandam described will keep the url from changing.

    • @glenn_nall:disqus Thanks for sharing your learnings.

  • numb

    Thanks for this, I found it very useful! I am pretty new to WordPress but here is my doubt:
    using multiple server names can cause any problem in the way contents are saved in the SQL database? I mean, whether I add contents (pages, media ..) from one hostname or the other does not affect the way these contents are going to be saved? Thanks

  • Thanks, actually a lot of functionality will probably work without this. (If you map the domains correctly, you can change the queries already based on hostname etc.) But, this will bring you into trouble at some point, your suggestion helped me fixing the broken infinity scroll on my ‘secondary’ domains for example, as now all the files are loaded from the correct domain.

  • Matthew

    Great solution. I did have an issue when using permalinks and a static home page. I was being redirected to “https:/” for some reason. I removed the permalink so ugly URI now, but it works. Would like to put the permalinks back in if possible.

  • Chris Dev

    Great post! Thank you!

  • Sebastian Krywult

    Does this work for multisite? I’m having a hard time getting it to work.

  • Lorenzooo

    The road to hell is paved with good intentions.

    And what is written above is a really bad practice…$_SERVER[‘HTTP_HOST’] is user input (the Host header in HTTP request)! You must configure your webserver/WAF/whatever to filter out host values not allowed, before employing this disputable snippet.

    Better, IMHO, employing an if…else condition to select the domain name.