Introduction
This article describes the list of steps that are required to redirect traffic from one website (domain 1) to another website (domain 2).
Assumptions
1. The existing website uses Route 53 for storing DNS records.
2. The existing website's web servers are hosted in Amazon EC2 and uses an Amazon Load Balancer. Furthermore, this article assumes that it is using a Classic Load Balancer (CLB). For redirecting traffic from one website (domain 1) to another website (domain 2), we require the use of an Application Load Balancer (ALB). So, it requires creating an ALB (if not already using one). This article also provides the details to create a new ALB.
Only Application Load Balancers (ALBs) support the advanced, content-based routing rules, including redirects. NLBs and CLBs operate at a different layer of the network (layer 4) and do not have the functionality to inspect the hostname and perform a redirect.
3. It is also assumed that all traffic to individual web pages in website 1 (domain 1) will be only directed to the main home page of website 2 (domain 2).
List of steps
- Log in to the AWS Management Console. From the services dashboard, go to Route 53. In the Route 53 dashboard, under the "DNS management" section, select "Hosted zones".
- Find and click on the hosted zone for domain 1 from the list. This is the domain/website you want to redirect from. (i.e domain 1 e.g example1.com)
- In the list of existing DNS records, search for the "Type" A or AAAA. Now check the value. If the value starts with "dualstack", it is most likely the DNS name of the EC2 load balancer. Log in to the AWS Management Console. From the services dashboard, go to EC2 => Load Balancing => Load balancers. Now choose the existing load balancer name and check its DNS name. If this DNS name matches with that of the value of the A or AAAA record (written above) that starts after the string "dualstack.", then it confirms that the DNS record's value is the DNS name of the EC2 load balancer.
- If the existing load balancer is a Classic load balancer (CLB), then create a new Application load balancer (ALB) and create the two rules similar to the existing two rules of the CLB i.e one for HTTPS:443 Protocol:Port and another for HTTP:80 Protocol:Port combination under the "Listeners and rules" tab. Then create an additional rule for each of these two lines (select each of these Protocol:Port lines => Manage rules => Add rule). If the existing load balancer is already an Application load balancer (ALB), then just create an additional rule for each of these two lines (select each of these Protocol:Port lines => Manage rules => Add rule).
- For the new rule, please follow the below instructions.
d) For Custom host, path, query put Host as Domain 2 URL/website 2 URL (for e.g example2.com) and Path as / and for Query do not make any changes (leave the default value as is). Let the status code be "301 - Permanently moved". The Path value of "/" helps in redirecting traffic for individual web pages in website 1 (domain 1) to only the main home page of website 2 (domain 2).
e) Save the rule
Disclosure
Parts of this technical article are prepared using responses from Google's Gemini AI. But everything has been successfully validated using a LIVE AWS environment before publishing this article.
No comments:
Post a Comment