Site icon Hip-Hop Website Design and Development

change home_url and site_url but don’t redirect to home_url and site_url on load

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

I want to change the home_url and site_url for all links in the website to uat2.example.com, but it should not redirect to uat2.example.com if 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 User land on a page using uat1.example.com and click on any link it will send me 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.