Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

heroku

dns

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?

like image 534
sergserg Avatar asked Dec 05 '12 02:12

sergserg


People also ask

How do I point subdomain to Heroku app?

Summary of stepsAdd the custom domain to your app with the heroku domains:add command. Look up the Heroku-supplied DNS target for the custom domain using the heroku domains command. Configure your app's DNS provider to point to the Heroku-supplied DNS target. Confirm that your app is accessible via the custom domain.

How do I redirect my domain to Heroku?

Go to the record editor and two DNS records, one for each host name, pointing to the Heroku SSL endpoint: Add an ALIAS record to point example.com to Heroku. Leave the Name of the record empty and set the Content field to the SSL endpoint example.com.herokudns.com. Add a CNAME record to point www.example.com to Heroku.

How do I link a Namecheap domain to Heroku?

First connect to the Heroku dashboard, select the heroku application and go to the "Settings" tab. Scroll down until you reach the Domain and certificates section. Click on the purple "Add domain" button and type the domain name with its subdomainyou want to use.

Can you buy a domain through Heroku?

Note: Heroku does not host domains and you cannot buy a domain through Heroku.


2 Answers

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.

Point namecheap domain to Heroku

Custom Domains | Heroku Dev Center

like image 51
richardpilgrim Avatar answered Sep 29 '22 01:09

richardpilgrim


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

like image 43
Ved Avatar answered Sep 29 '22 01:09

Ved