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

5

146

I am trying to figure out how to get the naked domain for my website to redirect to the www domain. I am using Heroku and have the domain from GoDaddy. Because of Heroku, my A records are already set up as:

@: 75.101.145.87

@: 75.101.163.44

@: 174.129.25.170

And my www CNAME points to proxy.heroku.com.

I've been looking all over the internet, but can't find a simple, free answer for how I can do this redirect. Some answers discuss using paid services, which I don't want to do, and others talk about going in and modifying Heroku settings, but then don't really give much explanation. Right now, if you go to my naked domain, it's just Heroku saying that no such app exists, while if you go to my www domain it's my app.

Unreflective answered 15/7, 2012 at 14:8 Comment(5)
The Heroku FAQ only says how to do the redirect with DNSimple. Their support page links to StackOverflow.Unreflective
I think Emil's response is a bit harsh on this, this site is a resource for solving problems we have along the journey of programming and that is a problem i'm having right now! :DMonnet
This should probably be closed as Dupe instead of Off-Topic: #16022824Stork
@ChrisMoschini the accepted answer at the question you reference does not work on GoDaddy because GoDaddy doesn't support ALIAS records, only CNAME. This is its own question I think.Lawrenson
Whatever A Records is set there is no possibility to have a naked domain pointed directly to heroku. We could only set it to be routed to www which CNAME is pointed to your-app-name.herokuapp.com.Gonococcus
C
235

On GoDaddy, use the "Forwarding" feature to setup a forward from yourdomain.example to www.yourdomain.example. 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.example 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.

Corody answered 15/7, 2012 at 17:47 Comment(8)
does this create a warning/error if your using SSL as heroku claims? they said if https:// example.com is redirected there is a warning.Carleycarli
@jaqx, this is happening to me, did you find a way to avoid users getting this warning?Handicraft
@Handicraft I just got tired of the hassle and switched to DNSimpleCarleycarli
This works, but the user ends up at www.example.com. I want them to end up at example.com. Is there a way to do this with godaddy?Moorfowl
@Moorfowl there's no way to do this with GoDaddy. Use the ALIAS/ANAME feature of other providers like DNSimple or DNS Made Easy if you require this.Corody
@RyanDaigle Thanks Ryan. I recommend everyone leave godaddy for more than one reason. NameCheap.com is who I use now. They are great, and they support what I was trying to do. Also, NameCheap accepts bitcoin.Moorfowl
The A record has changed: For your domain name to forward, its A record must be pointed to 50.63.202.1 (from the same link as in the answer)Burgage
CloudFlare will be the best solution, CloudFlare support "CNAME Flattening" FOR FREE, so you can create a CNAME record that sets root/apex/naked domain to yourapp.herokuapp.com.Carpi
O
22

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.

Otherness answered 25/3, 2013 at 1:37 Comment(3)
why pay another fee to someone else?Centigrade
You, sir, are a lifesaver. @Vezu: non-ssl forwarding is completely free. You just point your A record for the naked domain to that IP address and it will redirect the browser to the www domain. You don't even need an account with them.Linzer
I'm trying to incorporate wwwizer for mine, and in my A record I have the host as "@" and the points to as 174.129.25.170, per wwwizer's instructions, but I get their error message page when I visit my naked domain! Did I do this correctly??Galluses
I
8

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

Frequently Asked Questions

Can I point *.mydomain.example 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.example for my app?

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

 ! mydomain.example 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.example custom domain to one of their apps.

Immense answered 15/7, 2012 at 14:37 Comment(3)
Would the IP address and web address for Heroku be appname.heroku.com or proxy.heroku.com?Unreflective
You should really look at this article, devcenter.heroku.com/articles/custom-domains, as it covers everything that you're looking to do.Immense
This approach points the CNAME www to @ which still routes traffic through to fixed IP addresses (which has all the same downsides as A-records). Use a top-level redirect, on GoDaddy this is called "forwarding", instead.Corody
T
5

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.example$&', :if => Proc.new {|rack_env
  rack_env['SERVER_NAME'] != 'www.yourdomain.example'
 }
 end if Rails.env == 'production'

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

Trifacial answered 15/7, 2012 at 17:16 Comment(4)
Ideally, this is done at the DNS level avoiding a trip through Heroku's fixed IP addresses. Plus, not sure if this is a Ruby app or not?Corody
Ryan, redirects cannot be done on the DNS level. They are always done by HTTP.Yellowweed
Why as an initializer and why not just put it in the production environment configuration?Root
When I use heroku + my custome domain, must I have any A record pointing to heroku? If yes, what's its value?Degrease
M
3

For this to work with Network Solutions do the following:

Network Solutions pointing yourdomain.example to www.yourdomain.example. 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.example
host www.domain.example
Motif answered 14/2, 2013 at 2:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.