I have migrated my domains from another provider to Route53.
Everything is working OK except when I try to navigate to my website without the www's. I get a DNS error. I'm sure it's something elementary I've missed (Extra alias, cname entry etc.)
For clarity's sake - www.domain.com works and domain.com does not.
It sounds like you're missing an A record for the route.
Related
I've looked around trying to fix my website App Opps (appopps.com) to have a www subdomain. I've looked around on Stackoverflow but could not find anything to help me. I tried setting up a redirecting Alias Record Set pointing from www.appopps.com to appopps.com but that hasn't worked.
Error Message:
Record Set setup
Redirect setup
I'm sure I'm missing something super simple here and sorry for the basic question in advance!
EDIT
The www should use the same alias as the primary .com record (presumably your load balancer)
First of all, there's no such thing as a redirecting alias record.
With DNS records you can only achieve a behaviour that both www and apex domain will point to the same location. Any redirection from www to non-www (or vice-versa) is going to happen on a server of some kind. You don't have to provision that server though.
You could for example set a redirect on an S3 bucket (and also distribute it as a CloudFront distribution) to redirect to the desirable domain. Then you'd use the url of the bucket (or distribution) as the target for your Route53 record.
As always with DNS, you have to keep in mind that any changes made to your configuration may take some time to propagate (several hours).
I have my non-www domain.com with GoDaddy and my WordPress Blog is hosted in AWS EC2. I'm using Route 53 to handle DNS requests. The existing solution for my question, seen in many places(including SOF) is to create two S3 buckets in the name of non-www domain and www domain for redirection of static websites. This is not my case.
I've my WordPress installed in EC2 and not using S3 for holding my Data. I hope this is not a static website and cannot follow the general solutions available.
I tried the following solution around and did not work
I tried changing the C-NAME record to www.domain.com but it did not worked.
I tried domain forward feature available with GoDaddy.com and didn't work.
I tried modifying .htaccess file and that too didn't work.
This is what my record sets in Route 53 look like
Name Type Value TTL
------ ----- ----- ----
domain.com. A xx.xx.xxx.xxx (EIP) 300
domain.com. MX 1 ASPMX.L.GOOGLE.COM 3600
5 ALT1.ASPMX.L.GOOGLE.COM
5 ALT2.ASPMX.L.GOOGLE.COM
10 ALT3.ASPMX.L.GOOGLE.COM
10 ALT4.ASPMX.L.GOOGLE.COM
domain.com. NS ns-27.awsdns-03.com. 172800
ns-1190.awsdns-20.org.
ns-2028.awsdns-61.co.uk.
ns-855.awsdns-42.net.
domain.com. SOA xxxxxxxxx 900
How can I redirect my domain.com to www.domain.com?
I was hesitant to post my comment as an answer because there are a gazillion ways to setup and configure Wordpress it seems. Anyway, to keep in the spirit of keeping this question in the amazon-web-services tag I ran a test case deploying from the AWS Wordpress Cloudformation template. I'm not sure if this is how you actually installed Wordpress but here is one way to redirect:
Make sure that your Cloudformation template completes successfully.
Here is what my Hosted Zone looked like - I have not added A records yet.
Get the instance IP address. Note that in this example I did not setup an Elastic IP. Since I knew that I would not need to stop the instance temporarily I opted to just stick with the automatically assigned, random pubic IP.
Next I made an A record for the domain apex of that IP and then an A record for www. I also changed the TTL to 60 seconds.
Once DNS propagation completed I tried accessing my domain name. As you can see, the AWS Cloudformation Wordpress installation defaults to a different path and URL.
Using the URL, http://example.com/wordpress did the trick.
I didn't go through the steps but when you go to http://example.com/wordpress it starts a setup screen. Enter all the information like DB name and password, etc. and then login to the admin panel. Once you go through all of that you go to the General settings screen. This is where your configuration will probably be different but for mine, the URLs were listed as http://example.com/wordpress. I simply changed these URLs to http://www.example.com/wordpress. (As an aside, I also tried changing and saving the permalink section to generate an .htaccess file but one was not generated due to the inability to write to the file. I tried making my own but I kept running into "too many redirect" messages so this might not be a route you want to take depending on your install.)
You will need to make a change in the index.php file. For my installation it was located at /var/www/html/wordpress/index.php. Make sure to make a copy before changing it. I simply added /wordpress/ in front of wp-blog-header.php. Again, this install puts the Wordpress files in the directory /wordpress - your install will probably be different.
Next you need to copy that modified index.php file to /var/www/html/ and then restart the httpd service.
To test the change I cleared out my DNS cache and opened up the network section of developer tools in Chrome.
I then opened a new tab (have to open developer tools again) and then typed in the naked domain name.
As you can see, the URL redirected to www.example.com with a 301 permanent redirect.
I'll through another suggestion out here while I'm at it. You can use the free version of Cloudflare to just do the redirect for you. Cloudflare offers a bunch of other free and useful services like CDN so if you don't mind depending on a 3rd party service (a reputable one by the way) it might be easier with more value add. As I highlighted in the screenshot however, note that if you use forwarding you cannot use some of the other advanced rule sets.
Anyway, I hope this helps!
I own foo.com and bar.com. I am managing both in Route53. foo.com hosts my site, and I'd like to direct traffic from bar.com to foo.com. I tried to set up a CNAME record for bar.com pointing to foo.com, but I got the error message:
RRSet of type CNAME with DNS name foo.com. is not permitted at apex in zone bar.com.
Why doesn't this work, and what can I do instead?
As per RFC1912 section 2.4:
A CNAME record is not allowed to coexist with any other data. In
other words, if suzy.podunk.xx is an alias for sue.podunk.xx, you
can't also have an MX record for suzy.podunk.edu, or an A record, or
even a TXT record. Especially do not try to combine CNAMEs and NS
records like this!:
podunk.xx. IN NS ns1
IN NS ns2
IN CNAME mary
mary IN A
The RFC makes perfect sense as the nameserver wouldn't know whether it needs to follow the CNAME or answer with the actual record the CNAME overlaps with. bar.com is a zone therefore it implicitly has an SOA record for the bar.com name. You can't have both a SOA record and a CNAME with the same name.
However, given that SOA records are generally used only for zone maintenance, these situations where you want to provide a CNAME at the zone's apex are quite common. Even though the RFC prohibits it, many engineers would like a behaviour such as: "follow the CNAME unless the query explicitly asks for the SOA record". That's why Route 53 provides alias records. These are a Route 53 specific feature which offer the exact functionality you require. Have a look at http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/CreatingAliasRRSets.html
Create an S3 Bucket called bar.com. (The name must be the same as the domain you want to redirect from in order for this to work!)
In the bar.com S3 Bucket go to Properties > Static Website Hosting, select Redirect all requests to another host name and enter foo.com in the text box.
Back in Route 53, in your Hosted Zone for bar.com, click Create Record Set. Select A - IPv4 address for type. Click Yes for Alias. Click the text box for Alias Target. bar.com should be listed under -- S3 Website Endpoints --. Save the record. Wait a few minutes and you should have a redirect setup to redirect requests from bar.com to foo.com.
You can use this same method to redirect a naked domain to a subdomain (like www). I use this in cases where www.foo.com has to be a CNAME so I redirect from foo.com to www.foo.com with this same method. If foo.com is an A record, you can use this technique to redirect from www.foo.com to foo.com.
NOTE: this method will forward with the full path. i.e. http://bar.com/test will forward to http://foo.com/test.
On Route53, You need to create an A record NOT a CNAME record, and create an alias under that.
From #ewalshe's comment on Alexandru Cucu's answer,
if you came here trying to setup API Gateway with a custom domain name and have a Cloudfront distribution url.
Jonathan answer is correct. If you still confuse with his answer please take a look of this example.
tldr; You have to pass in an FQDN as the ResourceRecordSet name.
I had this same problem using this statement c# snip:
private static void RegisterHostWithDns(IAmazonRoute53 ec2,SynoviaImage image)
{
var changeBatch = new ChangeBatch();
var rRs = new ResourceRecordSet(image.Name, RRType.CNAME) {TTL=60,ResourceRecords = new List<ResourceRecord>() { new ResourceRecord(image.PublicDns)} };
var change = new Change(ChangeAction.UPSERT, rRs);
changeBatch.Changes.Add(change);
var request = new ChangeResourceRecordSetsRequest(ConfigurationManager.AppSettings["DnsZoneId"], changeBatch);
var response = ec2.ChangeResourceRecordSets(request);
Console.WriteLine("Updated CNAME For {0} setting {1}",image.Name,image.PublicDns);
}
In this case image.Name == "Listener"
Once I changed it to:
private static void RegisterHostWithDns(IAmazonRoute53 ec2,SynoviaImage image)
{
var changeBatch = new ChangeBatch();
var rRs = new ResourceRecordSet(string.Format("{0}.{1}",image.Name, "testing.foo.bar.com"), RRType.CNAME) {TTL=60,ResourceRecords = new List<ResourceRecord>() { new ResourceRecord(image.PublicDns)} };
var change = new Change(ChangeAction.UPSERT, rRs);
changeBatch.Changes.Add(change);
var request = new ChangeResourceRecordSetsRequest(ConfigurationManager.AppSettings["DnsZoneId"], changeBatch);
var response = ec2.ChangeResourceRecordSets(request);
Console.WriteLine("Updated CNAME For {0} setting {1}",image.Name,image.PublicDns);
}
now the value being passed in is: "Listener.fully.qualified.com"
It works now.
Please note that this error can happen if you forgot to enter something in the 'Record Name' field.
That is, it may expect www, and if you forgot that, you'll see the error, even if everything else is correct.
It's a small chance, but if you forgot to enter www in the 'Record Name' field, go and do that, and everything should work.
You should use the DNAME instead of a CNAME.
A CNAME record is only able to redirect the label to another label.
When you talk about redirecting domain names instead of labels, you should use DNAME
$ORIGIN bar.com
IN DNAME foo.com
This also means that every A, NS and any more records should be deleted. This have to be configured in the foo.com domain.
I'm currently using dotcloud hosting for an application and I'm redirecting my naked url using my domain registrar namecheap (through "#" hostname and "*" hostname as a URL direct- and then a cname for www to dotcloud)
This works well for re-directing people back to main www.
My issue is I want to map the visitor to the equivalent naked domain url they were trying to visit. E.g. http://example.com/websitepage1 to http://www.example.com/websitepage1. Right now visiting any page on the site minus the "www" will just redirect you to the homepage.
Any ideas or suggestions?? I'd prefer not to switch out of dotcloud hosting for the moment but will do so if it's impossible to get this to work another way.
Thanks!
UPDATE
The urls that need to be redirected are created dynamically so it's not impossible to hard code them. The DNS doesn't have to be namecheap. I can put the nameservers else where if there is an option that allows redirect of naked urls to the www equivalent. Any ideas appreciated!
You need to add rewrite rules to nginx.conf:
server {
server_name hostname.org;
rewrite ^(.*) http://www.hostname.org$1 permanent;
}
You can specify custom rewrite rules (and actually almost any Nginx setting) by creating a file named nginx.conf at the top of your app. http://docs.dotcloud.com/0.9/guides/nginx/
Given their documentation (0), it seems possible to do the following 301/302 redirects using Namecheap's forwarding options:
Setup a naked domain redirect from example.com to www.example.com
Setup a naked domain redirect with a url from example.com/url/ towww.example.com/url/`
I don't see in the documentation where it says they support a wildcard option, so for every url you'd like to support, it seems you may have to create a forwarding entry.
(0): http://www.namecheap.com/support/knowledgebase/article.aspx/385/77/how-do-i-setup-url-forwarding-for-a-domain
I have:
signed up for an AWS account
set up buckets for example.com and www.example.com
enabled website settings in properties for each domain
set bucket policies for both domains
created this cname record:
www > www.example.com.s3-website-us-east-1.amazonaws.com
Right now when a user goes to www.example.com, they see the index page, and everything is working just fine. When they go to example.com, there is nothing but darknenss and silence because the page just doesn't load (and gives 'connection timeout' error. )
What I want is for example.com to forward to www.example.com so that no matter what the user types in the browser, they see the site that is located at www.example.com.
How do I make this work?
Can I add a record of some kind at godaddy to make example.com redirect to www.example.com?
Do I have to get a static IP to make this work using s3? I keep reading about an elastic IP from EC2, but I am not understanding how I can set that up, or how it would work since I am not using EC2 at all for my website.
I think user Go Daddy's answer was correct, but I'll write up more succinct instructions that I followed to get the forwarding to work for me. I don't know why others are suggesting wwwizer, because GoDaddy uses a 301-redirect too (but maybe it didn't used to?). By the way, this answer isn't specific to Amazon's S3 -- it simply requires you have the "www" CNAME record set correctly.
Login to GoDaddy.com.
Click on My Account.
Click on the Domains product, and click the Launch button next to your domain.
In the Domain Information section you should see "Forwarding: Off". Click the Manage link next to it.
A Forwarding and Masking dialog box should come up. Under Forward example.COM to enter www.example.com.
Click the OK button.
The forwarding kicked in for me within maybe half an hour.
To note, in the dialog box you can change it to forward either "http://" or "https://". I only needed it for "http://", so I'm not sure if GoDaddy will forward both SLL and non-SSL at the same time.
Also, if you're curious, if you click on the Advanced Options link in the Forwarding and Masking dialog box, it should be defaulted to "Forward Only" and have the redirect type set to permanently forward your domain (which is what gives the 301-redirect).
You can use wwwizer's free naked domain redirect service:
http://wwwizer.com/naked-domain-redirect
Just put 174.129.25.170 as the A record for the non-www version of your domain.
fragholrok,
I'm glad you were able to find a way to get your site working. Admittedly, it's a little hard to understand exactly what's going on with your domain name without more specific info, but I wanted to jump in and mention one thing.
You weren't sure if you could forward your domain to the www subdomain. It depends how you have it setup - sometimes it will work and sometimes it won't. According to your original post, the www subdomain is setup with its own CNAME (as opposed to mirroring the main A Record). Because of this, you COULD forward your domain to the www subdomain - ie, forward domain.com to www.domain.com - using GoDaddy.com's domain forwarding functionality.
If, however, the CNAME for a subdomain is set to '#', which means it directs to the main A Record, forwarding the domain to the subdomain would not work.
I just wanted to clarify for anyone else who might come across this thread.
Good luck with your site,
Alon
GoDaddy.com Social Media
Sounds like your DNS/Name Servers on GoDaddy aren't set up right. They should have the information listed for the Nameservers somewhere where you're hosting the site.
EDIT: I've done some more looking around and it would Amazon doesn't provide you the Nameservers for S3. The "real solution" to this would be to set up a CName on GoDaddy. This site provides a lot of insight on doing that: http://www.google.com/support/blogger/bin/answer.py?hl=en&answer=58317
Also, this question seems to have come up before: Using GoDaddy Domain Hosting to link to Amazon S3 Website
I used the approach described in
http://thechrisoshow.com/2011/06/05/how-to-host-a-static-website-on-s3/
(also with godaddy).
It boils down to deleting the A host entry, creating a CNAME entry and using godaddy's forwarding functionality.
For me it is a partial solution. It works if I type
jaumebarcelo.info
in the url bar.
But it does not work if I click on a link pointing to
jaumebarcelo.info
or if I type
wget jaumebarcelo.info from the command line.
I am looking for the same answer. How I have done it in the past is with an apache htaccess rewrite. I may do it again this way.
RewriteCond %{HTTP_HOST} ^mysite\.com
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=permanent,L]
Here is one such page that talks about it.
If you need more help I would google htaccess and apache rewrites.
If you are using Route 53, you can create a new bucket with your naked domain name, and under 'Static Website Hosting', set it to 'Redirect all requests to another host name'.
Update : Jul 2019
Since the original accepted answer by Michael Krebs in 2012, screens/ui might have changed little bit.
Please follow the screenshots below for the latest steps as of today:
Then click on add.
If no A record and www sub-domain is bound with subdomain it should redirect root domain to www sub-domain. This is how it works with many other sites.