I'm having trouble with routing a subdomain to a Wordpress blog hosted on Heroku, and the root domain to another Heroku app.
If I have purchased a domain called cheese.com
on NameCheap and I'd like to route a subdomain like blog.cheese.com
how could I do this on Heroku?
What type of setting would I need to place on each Heroku application?
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.com
TTL: 14400
Type: CNAME
Address: 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 Redirect
Host 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.