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 https://example.com with my ALB and https://www.example.com 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?