Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

we have an app running on heroku. the dns setup is like this:

A record for domain.com -> heroku front end ip addresses CNAME for www.domain.com -> specific host name for our app provided by heroku

we also have an SSL cert for www.domain.com.

the issue is that if someone goes to https://domain.com/secure_stuff, they will get heroku's SSL cert, instead of ours, causing lots of fear. We can do things on our end to make sure that all of our URLs point to https://www.domain.com, but it still won't solve this specific issue.

is there a way to configure the DNS record to redirect all root domain traffic to the www subdomain?

share|improve this question

Heroku's support site does address the situation you're facing, which may help you with the problem.

On a couple of my sites, I solved the multiple domains/naked domain problem with a positive compare, i.e. if the domain is NOT www.example.com then perform a permanent redirect to www.example.com as this takes care of all issues in a very simple way.

RewriteEngine On
RewriteBase /

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] 

This question 'What is the best way to redirect my naked domain' addresses using DNS to solve the problem.

share|improve this answer
    
the heroku solution for this is actually discouraged by heroku, which is just using a different SSL option that they offer and A records. the issue with what you're proposing is that it still happens after the SSL handshake, which means that if someone got a hold of domain.com/stuff they would get a security warning, as the rewrite stuff wouldn't kick in yet. – kolosy Mar 13 '12 at 15:43
    
This is a bad answer and doesn't actually address the question asked. I signed up on this stack just so I could downvote but unfortunately don't have the rep. – codewizard Jan 12 at 17:14
    
@CodeWizard in fact the answer does force all non-www traffic to the www domain - I use it for exactly this purpose on a number of sites. If you still believe it's a bad answer then say why or what does work rather than spitting at someone else's attempt to help. – toomanyairmiles Jan 13 at 21:31
    
The question was "is there a way to configure the DNS record to redirect all root domain traffic to the www subdomain?" You're answer utilizes Rewrite module directives to redirect traffic. These are not DNS zone records. Your solution can be found abundantly all over the internet even at the time of writing, and did not require yet another example. Sorry to be picky, but the quality and relevance of content on stackexchange matters, at least to me. – codewizard Jan 13 at 21:45
    
@CodeWizard Yes, and there is a potential path to a solution on Heroku through the DNS record and that method is documented best in the Heroku support area which is the first link I provided in my answer. I then go on to say that I have used rewrite module to achieve a working solution in similar because, given the circumstances described, there may not be a working solution any other way - the code I supplied works with Apache, Apache2, and Nginx which comprise 75 - 80% of the servers within Heroku. – toomanyairmiles Jan 14 at 23:36

Your SSL certificate should cover your www and non-www version of your domain. From GoDaddy their Standard SSL says, "1 certificate protects www.securemywebsites.net AND securemywebsites.net"

And instead of a CNAME to your www why not an A record or @ to direct requests to www?

share|improve this answer

Try using a naked domain redirect service. I run my own EC2 redirector to do this for my sites that require it (S3 static web hosting for example), and free ones exist such as http://wwwizer.com/naked-domain-redirect

Point your zone apex to the IP they give you (A record) and when you hit the naked domain in a browser, you'll be redirected to the www. equivalent.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.