5

Every now and then some clients have multiple domains for the same site. For example domain.com and domain.org. Is it possible to have wordpress work with both domains at the same time? I typically see issues when trying to load resources because of Cross-domain access. I know that I could just point domain.com to domain.org in the domain settings, but I was wondering if that's the only way.

I searched for solutions here, but all questions are about how to setup multiple domains for multisites (which makes sense). Just to be clear, I am not running a multisite.

  • 3
    What you're asking about is called domain mapping, where a site has many alias' e.g. tomjn.com tomjn.co.uk tomjn.org all being the same website. However it would be simpler and more efficient to declare 1 domain canonical, and have the others redirect there, this simplifies login authentication and cookie setup, as well as issues with canonical locations of content and SEO – Tom J Nowell Feb 10 '15 at 18:08
9

Are you wanting for the exact same WordPress site to work on two different domain names, where all links and content would use either domain name?

If this were the case, you would run into Duplicate Content issues with Google, hurting your SEO pretty badly.

That being said, you still would have a very hard time getting WordPress to properly load your content off of either domain name. A variety of functionality uses the get_site_url function to construct the links on your pages, so all of your links would be using only the one domain within your Siteurl setting.

Even still, if you want to try and get really tricksy, you can use something like the following to define your Siteurl and Home in the wp-config.php based upon the Domain being passed to the site:

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/path/to/wordpress');
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/path/to/wordpress');
  • That's pretty much the answer I expected. Thank you. – gdaniel Feb 10 '15 at 18:48
  • does not work,, whatever i do if i browse to any domain added , i will get redirect to the original domain name – Zorox Aug 29 '16 at 17:58
  • Seems like this solution is no longer working. I tried the same but couldn't get it working. While it used to work with previous version of WP. – Abhishek Sachan Aug 21 '18 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.