Pointing your domain to Heroku has never been a straightforward process, especially if you have a complicated situation. For instance, if you want to keep your mail records at your current location, but point your domain to Heroku, or if you want to set up Google Mail or Outlook 365 on your Heorku domain.

For this tutorial, I am using one of the domains I own (liveoncassette.com) as an example.

Option #1 – Point your root domain to Heroku

Step 1. Create a new Heroku app

To point your root domain, you will need to login to Heroku and create a new app. Alternatively, you can create your new app on the command line with heroku create liveoncassette.

Create a new app on Heroku

Step 2. Add your custom domain name to Heroku

Let’s add our domain by navigating to settings inside of Heroku, and adding both liveoncassette.com and www.liveoncassette.com.

Alternatively, you can use the command line to add your domain heroku domains:add liveoncassette.com www.liveoncassette.com.

Create a custom domain on Heroku

Step 3. Install the PointDNS add-on

To point your root domain to Heroku, you will need to install the PointDNS add-on. This add-on is free but you will need to have a credit card on file with Heroku. To install this add-on, navigate to your app on Heroku and click on the resources link. Here you can search for PointDNS and provision the add-on.

Alternatively again, you can do this via the command line by navigating to your app, and running heroku addons:create pointdns:developer.

Install the PointDNS add-on
Provision the PointDNS add-on

Now, open PointDNS on the web or through the command line with heroku addons:open pointdns. Once PointDNS opens, click on your domain and copy your name servers.

PointDNS my domains
Copy your name server information

Now, login to your domain provider (Go Daddy) in our case, and change your name servers to match the information provided by PointDNS.

Update your name server information on Go Daddy

Once your name servers have been changed, wait an hour or so and log back into PointDNS. You should now see that your status is green, which means you are good to go!

Green means good to go

Step 4. Add email hosting (optional)

If you want to add hosted email, click on "1-click integrations" inside of PointDNS. Here you have several options including Google Mail. You can also add these records manually if you want to use Outlook 365 for sending emails etc.

Point DNS, 1 click integrations
Point DNS, 1 click integrations Google

Option #2 – Keep your root domain, and point WWW

If you want to keep your domain where it is, you should only point www to Heroku. This can be accomplished by adding a CNAME Record.

First, you will need to create a new Heroku app, as per step 1 above.

Add your custom domain name to Heroku

Next, add your custom domain by navigating to settings inside of Heroku and add www.liveoncassette.com. Note, here we are only adding www unlike step 2 above.

Alternatively, use the command line heroku domains:add www.liveoncassette.com.

Point WWW to Heroku

Now, go to your domain registrar (Go Daddy) in our case and modify your DNS records. Point www to the DNS target supplied by Heroku.

Add a CNAME Record for www

Re-Direct HTTP to WWW

The final step is to redirect all of our HTTP traffic to www. To do this you will need to create a permanent 301 redirect.

This is typically an option inside most domain registrars. You can also do this with your .htaccess file as per below.

Re-direct via .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]