Search code examples
ruby-on-railsheroku

Setting up a custom domain with Heroku and namecheap


I've followed all the instructions on https://devcenter.heroku.com/articles/custom-domains to get my custom domain set up, and it still isn't working.

On Heroku, I have the following domains:

myapp.herokuapp.com

example.com

www.example.com

And on Namecheap, I have the following settings:

HOST NAME | IP ADDRESS/URL | RECORD TYPE

@ http://example.com URL Redirect

www myapp.herokuapp.com. CNAME(Alias)


When I run: "host www.example.com" in my terminal, I expect to get "www.example.com is an alias for myapp.herokuapp.com". Instead, I get:

"www.example.com is an alias for myapp.heroku.com"

I can't figure out why it is pointing to myapp.heroku.com, because I have only specified myapp.herokuapps.com.

Does anybody know why this is happening?


Solution

  • 1) Go To Namecheap, and go to the domain you want to manage.

    2) On the left sidebar, click "All Record Hosts", NOT any of the other jazz other tutorials tell you. No DNS pointing changes are necessary. It's easier to use alias.

    namecheap sidebar all host records

    3) Once you do, you'll see a line starting with "www" as a CNAME (Alias) option. Fill this in as your heroku app's domain name example.herokuapp.com

    namecheap CNAME alias location

    That's it for namecheap.

    4) Then at heroku settings, under "domains", enter your purchased domain name you wish to be displayed.

    heroku settings domains

    That's it! It's as easy as letting heroku and namecheap know about both domain aliases.

    Credits to this blog: http://blog.romansanchez.me/2013/06/08/point-namecheap-domain-to-heroku/

    Update:

    Apparently, heroku will only allow sites with www. prepended. To have a true root domain without www. will take some extra ninja hacking.