How to point subdomain to a Heroku app, and root domain to another Heroku app? How to point subdomain to a Heroku app, and root domain to another Heroku app? heroku heroku

How to point subdomain to a Heroku app, and root domain to another Heroku app?


I'm not sure of exact directions for NameCheap but the general way to redirect a subdomain to the Heroku app would be to add a CNAME record to the subdomain. To redirect the root domain you will need to set a CNAME like functionality at the zone apex.

Subdomain

blog.cheese.com would have a CNAME record pointing to myblog.herokuapp.com, you may also want to create a CNAME record for www.blog.cheese.com.

An example record could be:

Name: blog.cheese.comTTL: 14400Type: CNAMEAddress: myblog.herokuapp.com

Once both CNAME records are set up you will need to tell heroku to point the domain to your app.

heroku domains:add --app myblog blog.cheese.com

If you do this for both your subdomains they should now point to your Heroku apps.

Root Domain

To point the root domain you will need to set a couple of records

Host Name: @      URL: http://www.cheese.com                Record Type: URL RedirectHost Name: www            URL: mymainpage.herokuapp.com              Record Type: CNAME (alias)

Once both records are setup just call the command below via Heroku to point your domains to it.

heroku domains:add --app mymainpage.herokuapp.com cheese.com

Here are a couple of places to look for extra information.

Point namecheap domain to Heroku

Custom Domains | Heroku Dev Center


You will have to add the custom domain to your heroku app - https://devcenter.heroku.com/articles/custom-domains - After setting the necessary DNS, you can add the wildcards