I have wordpress setup with the domain set as mydomain.com I have a secondary domain that is mydomain.com.au

Can I make wordpress use mydomain.com.au if someone comes to the site from a link that is mydomain.com.au. Any if they navigate through the site it stays as .com.au

But if they come from mydomain.com it stays on mydomain.com when navigating?

I've tried this but the url always shows as mydomain.com https://stackoverflow.com/questions/29915680/wordpress-2-domains-to-point-same-directory

  • can you please add your code?
    – inarilo
    Commented Jun 6, 2017 at 7:23
  • if your theme does not use those variables it may not work, another option is using htaccess redirects
    – inarilo
    Commented Jun 6, 2017 at 7:25
  • It might be tough because the site URL is recorded in the database. If you don't have to have both domains you could use a 301 redirect from one to the other. If what you are trying to achieve is sending us aussies to .com.au and others to dot com you might consider geo locating? Maxmind can check if ip is within australia. But it's not 100% accurtate. Commented Jun 15, 2020 at 8:55

1 Answer 1


There are several problems in your logic, as Wordpress won't know which domain is going to handle actions. Even if you use a symlink from the other domain to point to .com domain, or even if you use htaccess rules to redirect requests, when a user upload some image, will they be saved as .com.au images ? as .com images ? There are a lot of issues related with domains that you may properly think before to use two domains as a single one, but I think perhaps there's some solution using Wordpress MultiSite.

If you want this to work at any price, I think the best solution will be pointing the second domain folder as a symlink to the first one ( you will need ssh access to the server ) and use some rules on htaccess or within virtual host definition, to properly maintain .com.au urls as you want. Also, you should make the changes proposed on the solution you've mentioned ( so you will need to make this changes also: https://stackoverflow.com/questions/29915680/wordpress-2-domains-to-point-same-directory )

The htaccess trick could be as this:

RewriteCond %{HTTP_HOST} ^domain.com.au

RewriteRule ^(.*) http://domain.com/$1 [P]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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