0

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?

1 Answer 1

0

So this had been a constant issue for me but finally i got this working, thanks to this blog post. http://www.velvetblues.com/web-development-blog/turn-off-wordpress-homepage-url-redirection/

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.

 remove_filter('template_redirect','redirect_canonical'); 

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

Your Answer

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

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