DNS configuration to force root domain to www

10,330

Solution 1

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.

Solution 2

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:
10,330

Related videos on Youtube

user7424
Author by

user7424

bistro, ndjango. stuff.

Updated on September 18, 2022

Comments

  • user7424
    user7424 over 1 year

    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?