Reputation: 21
I want to set up in AWS a simple 301 redirect configuration from my 'non-www' URL to the 'www' URL.
example.com --> 301 redirect --> www.example.com
In AWS I configured Route 53 record set in this way:
www.example.com --> simple routing to my EC2 instance
example.com --> configured as an alias of www.example.com
In this way the redirect works fine, but if I check the redirect code with an online redirect check (like this link) the result is not 301 but 200.
So, this is my question: How can I configure Route 53 Record set to make a 301 redirect?
Thank you in advance and thanks for your time.
Upvotes: 0
Views: 5715
Reputation: 21
I made it in a easier way by creating a bucket on S3 named "example.com" (the same name as the to-be-redirect domain), then I set up "Static Website Hosting" property as "Redirect all requests to another host name" to "www.example.com".
Finally on Route53 I created a record set for "example.com", type IPv4, and I linked it to the Alias just created by making the S3 bucket.
It works!
Upvotes: 0
Reputation: 24573
Route 53 does not handle web redirects. You can, however, do this with Route 53 and a S3 bucket. Here are the steps to follow.
In your case the bucket would be example.com.
If you want to use an alias (basically a root CNAME, even though a root CNAME doesn't work), the configuration to change is on your EC2 webserver. It would need to do the redirect.
Upvotes: 1