How do I redirect a naked (apex) domain to www using Route 53? - redirect

I need to do a 301 redirect from example.com to www.example.com using Route 53 (and S3 if necessary). There are a few solutions for similar problems but they either do not address how to redirect from the apex or they simply don't work.
When I follow the steps here, Route 53 tells me I can't add a CNAME to the apex domain. Therefore, I'm stuck in the mud.
This seems dumb simple but Amazon is making it hard. Any help would be appreciated.

I just managed to figure this out yesterday:
Go to your S3 console at https://console.aws.amazon.com/s3/home and click Create bucket. For Bucket name enter in your naked domain name, e.g. for www.example.com, you would put just example.com. Then click Create.
Click on the name of the new bucket, then click Properties > Static website hosting. On the menu that appears select Redirect requests. For Target bucket or domain enter in the full domain, such as www.example.com. For Protocol put in the desired protocol, http or https. Click Save.
Open your Route 53 hosted zone by navigating to https://console.aws.amazon.com/route53/home and clicking Hosted zones in the menu to the left. Select your domain and click on Create Record Set. Leave the Name area blank, and leave the default type at A - IPv4 address. Select Yes for Alias, and click on the Alias Target textbox. You may have to wait a few moments for the values in the dropdown menu that appears to populate. At this point the menu should contain the S3 Website Endpoint you created in steps 1 and 2. Select it.
Lastly, click Create, and enjoy your new routing set-up!

Try making an alias record instead of CNAME.
Per this answer:
RRSet of type CNAME with DNS name foo.com. is not permitted at apex in zone bar.com

If you are using an Application Load Balancer, they added support for redirects. You point your zone apex at your ELB (using an Alias) and have ELB do the redirect to www.example.com
This seems like a much better solution than setting up a bucket, adding static hosting, redirect, etc.
https://aws.amazon.com/about-aws/whats-new/2018/07/elastic-load-balancing-announces-support-for-redirects-and-fixed-responses-for-application-load-balancer/

The necessary steps are as follows:
Create a new Bucket and call it exactly as your naked domain name (eg: example.com).
In the Bucket properties, select "Static Website Hosting" and make it redirect to your www.example.com domain. Click "save".
Go to your Route53 hosted zone, and create an A record. Mark it as an Alias, and from the dropdown select your recently created bucket.
You're ready.

For those who need to redirect a naked domain example.com to www.example.com
The best practice is to create a new Load Balancer
with Listener on port 80 http that redirect 301 to www.example.com
In case you have https running just add another listener on port 443 that redirect 301 to www.example.com
Once you have finished with the listeners go to
Route 53 > your domain> Create Record
that points your new load balancer with the redirect listeners
record name: example.com
Record Type: A
Alias: Yes
Alias to Application and Load Balancer...
Select your location
Select your new Load Balancer
Save it and wait some minutes and now all request for naked example.com redirect 301 to www.example included for https request.
Note:
If you want to redirect http request to https request you need to do the same procedure but instead of a redirect listener you need to set-up a forward listener to https.

Related

Route 53 domain only works when prefixed with http(s)://

I have an application that runs fine in AWS App Runner and can be found here: https://iyarles.net
However, it's not accessible via the naked domain name iyarles.net.
Clarification comment: If I goto iyarles.net in my browser (edge), the request times out. If I goto iyarles.net, my website loads fine.
The App Runner service has a custom domain configured and my hosted zone has the 2 certificate validation records and the alias record pointing to my service.
A few weeks ago I transferred my domain from Google Domains to Route 53. It was originally a redirect from iyarles.net or any other subdomain (with or without https://) to the default domain for my service.
How can I replicate the previous behavior? What exactly are these alias records doing?
When you type the hostname into the browsers address bar, browsers will assume you want to make a plain HTTP request.
When you explicitly include the https: scheme, browsers will make a secure HTTP request.
Your server is running an encrypted service on port 433. It is not running a plain service on port 80.
It times out if you type http://iyarles.net too.
The issue is that the custom domain configured in AWS App Runner is not accessible via the naked domain name, iyarles.net. To replicate the previous behavior, you will need to create an Alias Record in your hosted zone in Route 53, which will point your domain name to the service URL.
The Alias Record is used to route traffic from a domain name to the service URL. It will ensure that any requests to the domain name will be routed to the service URL, thereby allowing your application to be accessible via the naked domain name.
It is important to note that you will also need to create two Certificate Validation Records in your hosted zone in Route 53. These records are used to validate the SSL Certificate for your domain name, which is necessary for HTTPS connections.

IP Redirect using DNS Server

For my current project I have an ADDS set up. The ADDS also has a DNS Server installed as a role. The name of my ADDS is corp.nikali.lan. I have to use the DNS Server role to redirect.
The IP address of outlook.com should be reachable by typing email.corp.nikali.lan.
At the moment all I have is the basic set-up after downloading the DNS feature. No added records or anything else.
CNAME record - records refer to an alias or redirect for a specific site or subdomain.
Two CNAME fields:
Name
Destination
Common CNAME entries:
Name: www
Destination: #
(or "yourwebsite.com")
Best example :
www.facebook.com and fb.com , some people are using a shortcut word like fb.com , you need to configure in your (NS) Name server , like the example above CNAME entries.

Redirecting sub-domain to specific URI

I want to redirect my subdomain to specific URI without making any changes to my code.
I found the domain forwarding services from Bigrock, they have a sub-domain forwarding service which specifies all subdomains will be redirected as "subdomain.mydomain.com to yourdestinationurl/subdomain/"
I replaced yourdestinationurl, with www.mydomain.com but it's not working.
Am I doing something wrong?Is there any alternative way to do this?
You may create the subdomain in the DNS Manager/Domain name zone file and point it to any URL using 'URL-Redirect' DNS record.
In other words, you need to login into the account of your domain name registrar (if the domain name is delegated to the default nameservers) or into your hosting cPanel (if you have a hosting plan). Then you need to find where to configure DNS records and configure URL-Redirect (also called URL-Forwarding) for your subdomain.
There is no need to have any plugins.

Stopping the naked domain redirecting to www

i recently migrated my application to AWS and setup a cname for www.domain.com and a redirect for the domain.com to redirect to www.domain.com.
The problem is, an external service was using a path on the naked domain.com (something like domain.com/external/service/) But with the redirect all HTTP POST data is being dropped with the redirect and i cant change the url that the external service is calling.
To fix this, i have setup my naked domain on route53 to point to my elastic load balancer where my app is located. I set up an A record pointed at my elastic load balancer using an alias.
Its been two days now and my naked domain still redirects to www. and therefore the external service is down. Any ideas on what i could do?
I am taking a long shot - there are different possible problems:
You are forwarding naked domain via A record to ELB, but your EC2 instace (say Apache) is still doing a redirect (not DNS, but http 301) back to www.
Check the DNS TTL. If the TTL is too large (say 48 hrs), then it takes that time. You need to wait longer.
Is Route53 fully managing your DNS? One possibility is that, somebody else like Godaddy is still doing the DNS for you - so nobody is contacting Route53 for the change to reflect.

DNS Redirecting into Another website

I own a website(A) and used blogger platform in web domain.Last month blog get deleted and i couldn't redirect it(A) into another new blog.As it is(A) domain only(No hosting), Can i redirect that domain(A) into my another website (B) which has Hosting in it(B) ??
You could change your DNS settings for your domain (of website A) to point to the IP address of your server for website B or also simply use a CNAME record which would point to your FQDN for website B, for example: www.websiteA.com CNAME www.websiteB.com.
There may be further configuration required for your host so they know to serve your website from requests to websiteA.com.
Note: This will continue to display as www.websiteA.com/page in your browser and not do a true redirect to www.websiteB.com/page.