Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku/GoDaddy: send naked domain to www [closed]

On GoDaddy, use the "Forwarding" feature to setup a forward from yourdomain.com to www.yourdomain.com. The forwarding feature can be accessed in the Domain Manager at the bottom of the "Domain Information" section:

Domain forwarding in GoDaddy

If you do this then all traffic to yourdomain.com will be routed to the Heroku app CNAME (which is the better approach).

One note, however, if you are on the Cedar stack then don't use proxy.heroku.com for the host of your www CNAME. Instead use your-app-name.herokuapp.com. These details are covered here.

GoDaddy also specifies that in order for your domain name to forward, its A record must be pointed to 64.202.189.170 or must fall between the following ranges: 50.63.202.1 - 50.63.202.31 or 184.168.221.1 - 184.168.221.31.


You could also use http://wwwizer.com to forward from your naked domain to your www. In GoDaddy in the DNS manager under the A record in the @ heading type in 174.129.25.170. They will automatically redirect from the naked domain to one with www. in front of it.


In GoDaddy's DNS Zone Editor, you will want to configure your CNAME record www to point to @. In your A Record, you'll use a wildcard (*) to point to the IP address and a second A Record that uses @ as the host that will also point to the web address. This way,

subdomain1.example.com will forward to your IP
www.example.com will forward to your IP
silly.example.com will forward to your IP
anything.example.com will forward to your IP

enter image description here

Frequently Asked Questions

Can I point *.mydomain.com to my Heroku app?

Yes, using the free Custom Domains feature of Heroku you can point a wildcard domain to your application.

What IP addresses should I use to point my custom domain to Heroku?

The Heroku routing stack uses a collection of IP addresses that can change at any time, and using A records to point to your app is not supported. To ensure your domain always points correctly to the routing mesh, configure subdomains (e.g. www in www.example.org) using a CNAME record:

If the app is on…   Then CNAME the subdomain to
Bamboo  yourapp.heroku.com
Cedar   yourapp.herokuapp.com

Naked (or bare/apex) domains (e.g. example.org) should be avoided because of their availability and uptime consequences.

Why can't I add subdomain.mydomain.com for my app?

In some cases, attempts to add a custom domain (like subdomain.mydomain.com) for an app may result in an error like this:

 ! mydomain.com is owned by another user

All applications for a given base domain must be owned by the same Heroku account. The above error means that someone else has already added a mydomain.com custom domain to one of their apps.


If you have the IP addresses setup on your naked domain and your www cname'd to yourappname.herokuapp.com then all you need do is use something like RackRewrite in your application to redirect the requests when they arrive at your application.

What you want to setup is any request to the naked domain gets redirected to your www address. After following the installation instructions add an initializer in config/initializers

 ApplicationName::Application.config.middleware.insert_before(Rack::Lock, Rack
 r301 %r{.*}, 'http://www.yourdomain.com$&', :if => Proc.new {|rack_env
  rack_env['SERVER_NAME'] != 'www.yourdomain.com'
 }
 end if Rails.env == 'production'

Which is saying, if the requested URL is not www.yourdomain.com then 301 redirect it to the www.yuordomain.com but only if it's running in production.


For this to work with Network Solutions do the following:

Network Solutions pointing yourdomain.com to www.yourdomain.com. Here's how.

  1. Within Account Manager, select My Domain Names

  2. Select the domain name that you want to manage

  3. In the green box, select Change Where Domain Points

  4. Select Advanced DNS, then Continue

  5. First, edit the A Records by selecting Edit A Records

    For the "@ none" enter the following IP address 205.178.189.129, clear the records for the "www" and "* (All others)", then select Continue

  6. Second, edit the Host Aliases (CNAME records) by selecting Edit CNAME Records

    Enter "www" in the Alias column

    Leave TTL set to 7200 but on the same line, enter the name servers provided by the blogging service in the Other Host section [ IE FOLLOW THE HEROKU INSTRUCTIONS NOW www --> yourapp.herokuapp.com (Cedar Stack) ]

    Select Continue

Now wait and check the domain(s) with the following terminal command:

host domain.com
host www.domain.com