Search code examples
amazon-web-serviceshttp-redirectamazon-ec2subdomain

Redirect a Subdirectory url to another instance in AWS without changing URL


I have the following set up under one account:

  • Domain: example.com with DNS administrated by AWS Route 53
  • Hosting App: A Webapp with an AWS ELB under www.example.com
  • Hosting Blog: A Wordpress Blog in a separate AWS EC2 Instance, at the moment with the link blog.example.com

What I want to achieve: Example.com/blog -> Redirecting to the Blog in AWS EC2 Instance so that all the pages will be displayed like example.com/blog/entry1 and example.com/blog/entry2, etc.,

My problem: Route 53 only allows subdomains like blog.example.com.


Solution

  • Either setup path based routing in an Application Load Balancer (you would need to switch to an ALB if you are currently using a classic ELB), or place CloudFront in front of your domain and configure it with two sources.