I followed the accepted answer here:
Cloudfront redirect www to naked domain with ssl
Here is what I did:
Create two S3 buckets named: example.com and www.example.com.
2.Turn on the Static Website Hosting on these two buckets.
3.Configure redirect in bucket www.example.com to bucket www.example.com. Protocol I chose https
4.For these buckets create two CloudFront Distributions. Each of this distributions point to corresponding bucket:
For Origin Domain Name provide bucket urls provided in Static Website Hosting section. The urls should have form (or similar): example.com.s3-website-us-west-1.amazonaws.com
On both distribution set HTTP to HTTPS redirect.
Route 53 configure DNS by setting:
An Aias records for example.com to point to corresponding CloudFront distribution.
An CNAME for www.xample.com to point to corresponding CloudFront distribution
The result:
http://www.example.com gets redirected to https://example.com
https://www.example.com gets redirected to https://example.com
This is the strange one:
When I enter example.com directly on my browser, I noticed that it gets redirected very quickly to http://www.example.com or (or https://www.example.com, it's too fast, I can't see it well), then immediately gets redirected to https://example.com.
Why there is a double direction here?
thx.
Related
So I'm trying to figure out if this is something I can configure through my DNS host or if I need to set this up on my app server.
My situation
I have a heroku app and domain name (lets say example.com) which is set up for https on both www and root/apex. So https://example.com and https://www.example.com both work. I am also able to redirect any http requests (both www or root/apex) to domain to the https equivalent so in other words:
http://www. redirects to https://www. and http://root redirect to https://root.
My issue
I want all combinations of my urls (http or https and www or root) to direct to a single url (https://www or https://root). My aim is to just have consistency in the urls. I noticed that most redirects work EXCEPT when trying to redirect from https://example.com to anything else.
What is the DNS host approach for this? And if it's not possible from DNS host the normal approach?
DNS provides translation from the domain name in a URL to an IP address that the client can contact. If your problem involves anything else whatsoever in the URL, it's not a problem DNS can solve.
The problem you describe involves the difference between HTTP and HTTPS. This is not part of the domain name in the URL. Therefore, DNS is not your problem.
Hiyas, Im trying to redirect my non-www domain to a digitalocean droplet serving localhost:3000. When I type in my http://non-www domain, I get a 302 redirect to the https version of the non-www domain.
Here's the pastebin to my config stuff - http://pastebin.com/89HP07cW
I also added A record to digitalocean domain, to point to ip. And 2 cnames, * points to #, and www points to #. I'm just hacking now, reading through all the solutions and config file seems straight forward, but not working for me.
I am using Github Pages as my hosting site for my domain. The pages are hosted at username.github.io. As per github pages documentation I have put the CNAME file in the root directory pointing to example.com
And in my godaddy DNS manager I have added CNAME www to username.github.io
Later I switched to CloudFlare to use the Universal Free SSL for my Github Custom Domain page.
Currently the CloudFlare DNS Manager includes these two items:
A exmaple.com 192.30.252.153
CNAME www username.github.io
Since I have enabled SSL in cloudfare and redirect http (naked or otherwise) addresses to https, I have put a Page Rule as http://*example.com/* with Always use https turned on.
Now all types of addresses are getting redirected to https://example.com (this is my end requirement)
However the 301 redirection from http://www.example.com to https://example.com is happening this way:
http://www.example.com to
https://www.example.com/ to
http://example.com/ to
https://example.com/
This multiple redirection will affect the site loading speed if a user types the address as www.example.com. And (possibly?) these multiple redirections will affect page ranking in search sites.
Hence is it not better to put direct 301 instead of multiple? Or using multiple redirection is what normally all web-masters do in a situation like this?
If no, then someone please guide me to enable the 301 redirection from http://www.example.com directly to https://example.com/ without any multiple redirections.
You can set Page Rules in CloudFlare and change the order to your intended effect.
If this is still problematic you can also enable HSTS which will require the browser to access the HTTPS version after the first time you visit the site. This also makes the site more secure by not allowing anyone to man-in-the-middle your secure connections.
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.
To replace a legacy web site, a client has pointed their DNS at my server where a new version of the website exists.
However they still serve http://support.example.com from their own server.
I have noticed that non-www requests, e.g. http://example.com still point to their own server, therefore show the old web site.
How can I point non-www requests, http://example.com at my server without breaking the functionality of their 'support' sub-domain?
The client's server is a Microsoft server, mine is Linux/Apache
Edit: Changing the DNS 'A' record will not break the existing sub-domain
I know I could add an index.html page to the front of the old site, but if it was ever deleted the page requests would cease to work
I can't use mod-rewrite because I don't have access to their web server files
PROPOSED SOLUTION:
On the client DNS, create an A
record for:
support.example.com – IP of the client's server
example.com – IP of my server
www.example.com - IP of my server
No need for any DNS changes on my server regarding this domain
Changing the A record for example.com won't affect the A record for support.example.com.