Adding Custom Domain Name

Author

Jade Danial

Calendar

08 02, 2020 11:17 AM

Feedback

0 feedbacks

View

545 views

A customized domain name helps you to establish your blog as a professional brand. It also ensures a blog’s success in multiple areas, search engine rankings, quality traffic, Google Adsense approval, community building and more. Every blog is special, but it needs to be discovered first.

 

 

Today I bought a domain name from Porkbun.com which is "codehubbyjadedanial.com" and I bought it for $5 for 1 year.

 

 

For my Heroku app to be available in my custom domain "codehubbyjadedanial.com", I need to point my custom domain to my Heroku app URL. To achieve this I need to add my custom domain to Heroku which will give me a DNS target domain. The DNS target domain can then be added to my domain hosting site's CNAME. And this will make my app available at "codehubbyjadedanial.com" and "www.codehubbyjadedanial.com".

 

 

 

Modify settings.py File

 

 

Before anything else, I need to modify my settings.py file to add my custom domain name in the ALLOWED_HOSTS  which is ".codehubbyjadedanial.com":

 

ALLOWED_HOSTS = ['127.0.0.1', '.herokuapp.com', '.codehubbyjadedanial.com']

 

 

After modifying my settings.py file I push it to my Github and Heroku account by running the command:

 

git status
git add .
git commit -m "Update settings.py for ALLOWED_HOSTS added custom domain."
git push origin master
git push heroku master

 

 

That's it, my app is ready to add a custom domain name.

 

 

 

Adding Custom Domain Name

 

First things first I go to the dashboard in Heroku.

 

I click my app name and then I click the "Settings".

 

Then I click on the button "Add domain".

 

After that a small screen pop-up then I type in the text field "www.codehubbyjadedanial.com" then I click the "Save changes" button.

 

I add also another domain "codehubbyjadedanial.com" for the Alias name without "www"

 

After the above steps, a two DNS target added.

 

I go to Porkbun.com and log in to my account.

 

Then I click "Domain Management" under my username.

 

In my custom domain, I click the "Edit" below the DNS Records, then a Manage DNS Records screen appeared.

 

In the Type field I choose "ALIAS - CNAME flattening record".

 

In the Host field, I leave it blank.

 

In the Answer field, I put the DNS target from Heroku where the domain name without "www" which is "codehubbyjadedanial.com" only.

 

Then I click the button "Add".

 

I add another record which is Type "CNAME - Canonical name record".

 

In the Host field, I type "www".

 

In the Answer field, I put the DNS target from Heroku where the domain name contains "www" which is "www.codehubbyjadedanial.com".

 

Then I click the button "Add".

 

 

That's it! After a few minutes, my Heroku app is available in the custom domain name "www.codehubbyjadedanial.com" and "codehubbyjadedanial.com".

 

 

 

 

Please feel free to submit the feedback below. I appreciate it.

 

Thank You and Happy Coding.



0 Feedbacks

Jade

Jade Danial is a passionate programmer and creator of Code Hub blog. He is fueled by his passion for learning. He is fascinated by the idea of discovering the world of programming.


Meanwhile, he is developing desktop and web applications using his skills in programming.

Get In Touch With Me

Facebook

Facebook

Dev.to

Dev.to

Github

Github

LinkedIn

LinkedIn

Twitter

Twitter