How do I redirect my naked domain (with SSL) on Heroku?

Do you have problems redirecting your naked domain with Heroku? Don't worry, we are here to help with a simple how-to that will guide you through all steps necessary to redirect your naked domain. Let's get started:

Step 01: Check if your www domain is pointing to Heroku

First things first: you need to make sure that your www domain is pointing to Heroku and set up correctly. Go to your Domain provider and check that there is a CNAME Record for your www domain. Is it already pointing to Heroku? Great, then it is time to move on to step 02. If it is not set to redirect to Heroku yet, you want to add that now. Go to your application page in Heroku and copy the details for the CNAME record. Paste it into the CNAME Field in your domain providers interface and voilà, you are ready to move on to step 02.

Step 02: Redirect your naked domain

Please note: The following process is pretty time consuming. Therefore we built NakedSSL to solve naked domain redirections hassle-free and without all the frustrations. Check now if we can redirect your naked domain for you or scroll down to get to the DIY how-to guide.

Enter your naked domain to see if we can help:

Do you have a valid SSL certificate installed? Check these guides:

Get a SSL certificate
https://

If you don't have a certificate for domain.com redirecting from https://domain.com to https://www.domain.com will not work, because before the browser gets the redirect it has to successfully establish the SSL connection (https is http inside SSL) and this fails because the certificate does not match. First of all, you need to have a valid SSL certificate for both your www and naked domains. You can buy your own SSL via RapidSSL from The SSL Store. After getting the certificate, you need to install the certificate on your server, and this gets even harder, but here are a few ways to set it up:

You could use an if condition in your Nginx configuration, e. g. like this:

server {
listen 443;
server_name domain.com;
if ($host = domain.com) {
rewrite ^(.*) https://www.domain.com:443$request_uri? permanent;
}

Or you could use the following configuration to create a 301 redirect for your naked domain:

server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;

return 301 https://www.example.com$request_uri;
}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
return 301 https://www.example.com$request_uri;
}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.example.com;

====>>> Your site configuration goes here <<======
}

If that process seems a little complicated, don't worry — we got you covered. NakedSSL is easy, simple, and convenient and will guide you through an easy process of redirect your naked domain.

NakedSSL: One domain, free forever:

Start with our free single-domain plan and upgrade only if necessary: NakedSSL offers 3 different plans for all your needs.
Need even more domains? Just contact us.

Single Plan

1 domain

FREE FOREVER

(or until we are broke)

Sixpack Plan

6 domains

€4.99 / month

€49.90 / year

Shitload Plan

25 domains

€16.99 / month

€169.90 / year