问题
Apologies if my terminlogy is not quite correct here
I have the domain albunack.net working fine on Route53. I also have domain albunack.com under Route 53 control
I want any requests to albunack.com to redirect to albunack.net and also to show the user they are on albunack.net not albunack.com (via the webbrowser address)
I tried creating an A record as Alias for albunack.com and setting alias target to albunack.net but that didnt work it didnt recognise albunack.net , how am i meant to do it ?
回答1:
You can do this by using an S3 bucket to redirect to albunack.net. First, you'll need to create an S3 bucket and point albunack.com to it.
- Create an S3 bucket called albunack.com (the name is important and must match the domain name).
- Configure the bucket to act as a static website. Do this in the bucket properties. Go to Static Website Hosting and select Redirect all requests to another host name.
- Enter http://albunack.net as the address you want to forward all requests to.
- Go the Route 53 and point albunack.com to the S3 bucket. You can do that by creating an alias record for the S3 bucket.
Now when users go to albunack.com, the request will go to the S3 bucket which will respond with a redirect to albunack.net. You can see a description of this technique at Root Domain Website Hosting for Amazon S3 on the AWS blog.
回答2:
Is not necessary use a s3 bucket for redirect or forward a domain to another. The simplest solution for me was make a rule over listener port 443 and in port 80
IF Host is example.com THEN Redirect to https://www.yourdomain.com:443/#{path}?#{query} Status code:HTTP_301
And the same rule for *.example.com
Consider that you need have the same ssl certificate for all your domains in your Route 53 service.
Listener Rules for Your Application Load Balancer
回答3:
I want any requests to albunack.com to redirect to albunack.net and also to show the user they are on albunack.net not albunack.com (via the webbrowser address)
This is actually something that you need to do from the web server, not through DNS. Actually DNS is tangentially involved as well.
The first thing you need to do is have both domains resolve to the same IP address. This can be done by either creating A records for both domains as you described doing, or setting one to CNAME to the other. But whatever approach you take, all DNS is doing is resolving a domain like albunack.net to an IP address. DNS doesn't provide a mechanism for a web browser to switch to a different domain.
Your web server is what will need to recognize when a request comes in for albunack.com and redirect them to albunack.net. Exactly how you do this is going to depend on what web browser you are using. I'm familiar with Apache, so here's a simple way you can do it using a virtual host definition:
<VirtualHost *:80>
ServerName albunack.com
RedirectPermanent / http://albunack.net/
</VirtualHost>
You'll find that redirection in web browsers has been discussed/answered quite a bit on stackoverflow & serverfault, so if you need more help with setting up redirects in whatever web server you're using then I'd start by searching for existing answers.
回答4:
Using a CNAME record is not possible for the so called zone apex. [1][2]
I found out it is neither possible to achieve this with an alias record. [3]
However, there is a trick how a zone apex redirect can be achieved using an HTTP code 301 if no SSL is involved. [4]
In a forum thread an AWS official explains why it is not possible to redirect a zone apex: [5]
We do not currently support a way to point what is sometimes called the "zone apex" to another DNS name. For example, it is easy to set www.example.com to be a CNAME to srv123.ec2.amazonaws.com. Unfortunately, the rules of DNS forbid CNAMEs at the zone apex, so you cannot set example.com to also be a CNAME for srv123.ec2.amazonaws.com.
They propose the following two workarounds:
There are two main ways to accomplish the goal of letting people visit your website via example.com. Some sites use an HTTP "rewrite" service that simply issues an HTTP redirect from example.com to www.example.com. We do not offer this service as part of Route 53, but it is something you can setup on your own using EC2.
The other option is to have example.com point to the IP addresses of the destination by configuring one or more "A" records (address records) for example.com. You can do that if you know the destination IP addresses are fixed, such as if you are using EC2 Elastic IP addresses. In the case of variable destinations like a CloudFront distribution, the destination IP addresses change all the time so you can't statically configure an A record.
References
[1] https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/ResourceRecordTypes.html#CNAMEFormat
[2] https://forums.aws.amazon.com/thread.jspa?threadID=95588
[3] https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-values-alias.html
[4] https://aws.amazon.com/premiumsupport/knowledge-center/redirect-domain-route-53/
[5] https://forums.aws.amazon.com/thread.jspa?threadID=55995
来源:https://stackoverflow.com/questions/29669779/how-do-you-redirect-from-one-toplevel-domain-to-another-using-route53