0

I have two domains uat1.example.com and uat2.example.com pointing to the same wordpress installation.

I want to change the home_url and site_url for all links on the website to uat2.example.com, but it should not redirect to uat2.example.com if the request comes on uat1.example.com,

So suppose someone visits my website, uat1.example.com; it should load it. But all links on the web page then should point to uat2.example.com. So if the User lands on the page using uat1.example.com and clicks on any link it will send the user to uat2.example.com; that is ok.

I tried putting this in config:

define('WP_HOME','http://uat2.example.com');
define('WP_SITEURL','http://uat2.example.com');

but when I visit uat1.example.com it is redirecting me to uat2.example.com, which is obvious. but I don't want that.

Do we have any trick so that home_url and site_url remains uat2.example.com only? But when I visit uat1.example.com, it doesn't redirect me to uat1.example.com and still consider uat2.example.com as home_url for all links on that page?

1 Answer 1

0

You need to set the WP_SITEURL and WP_HOME in wp-config.php file. Please add below code.

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

In your server SSL setup then used below code

define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST']);
1
  • As I mentioned, it is already added but this will then change all links on the page to requesting domain. I want to keep my all links pointing to uat2.example.com even though user visits uat1.example.com Jan 10, 2018 at 7:04

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.