How to access my wordpress application using two URLs?

I have deployed a simple self managed Wordpress application on AWS. My setup looks like this.

AWS CloudFront -> AWS ALB -> EC2 servers [ wordpress runs] -> RDS Database

I have associated a base domain say with my ALB and with my Cloudfront distribution. The issue is that at any point in time, I am able to access the website using only either of the two URLs. And I have figured so far that the Wordpress automatically redirects me to the URL which i mention in the Site URL and the HOME URL settings in the admin dashboard.

As an example, if i updated my site URL and HOME settings to point to my CF URL, and then type my ALB domain name in the browser, I automatically get redirected to the CF URL. Upon inspecting, i see a 301 status code and then this as one of the response header. X-Redirect-By : WordPress

The version of PHP/wordpress that i am hosting is PHP/7.2.34.

How can I stop this automatic redirection? How can I access my website using both the URLs?


So this had been a constant issue for me but finally i got this working, thanks to this blog post.

It seems like adding this in the functions.php file for the enabled theme works. Pasting here for anyone who may be facing a similar issue.


I restarted the httpd and the php-fpm service, and now i am able to make it work as expected.

Previous : Install new version of C-ares on Centos 7
Next : Is there a way to requeue bounced mails in Postfix?