Amazon Route 53 with Lightsail and Naked Domain Redirecting

Share This Article

(Update in June 2019:  you might want consider using the Bitnami Configuration tool which should solve this)

Using Amazon Route 53 (for both domain registration and DNS) has its advantages. Today I bought a new test domain and once it is set up in Route 53, a hosted zone was immediately set up and within seconds, the domain was already easily accessible. It was quick and fast.

But using Amazon Route 53 has its pain. Some functionalities in traditional domain registers are painfully missing in Route 53.

Why we cannot do re-directing of naked domain in Route 53

An example is re-directing of naked domain. What that means is when you enter “patnotebook.com”, you will be automatically directed to “www.patnotebook.com” (if that’s what you want). To do that in traditional domain registers, it is easy.

E.g. GoDaddy

GoDaddy Naked Domain Redirect
GoDaddy Naked Domain Redirect

E.g. Enom with Google Apps

Enom Naked Domain Redirect
Enom Naked Domain Redirect

E.g. Namecheap

Namecheap Naked Domain Redirect
Namecheap Naked Domain Redirect

The point is, for better or worst, it is just there in one of the settings.

In Amazon Route 53, that does not work easily. Don’t believe ? Today I bought a new domain. Once it is registered (and using S3 bucket for static page hosting), the DNS Propagation was quick and the web page was working.

For this domain, the naked domain worked:

Nake Domain Working
Nake Domain Working

For this domain, out of the box, the www domain DOES NOT work:

WWW domain not working
WWW domain not working

How to solve this issue of Naked Domain Redirecting

So what can we do. There are a few solutions. One of which is using Amazon S3 (yet another paying service) to do so. For some of my clients’ web site that runs WordPress on Amazon Lightsail, I choose to use the redirect method at the application level (Apache and WordPress).

The key to this is this article: How To Redirect Myapp.example.com To Www.myapp.example.com?. This is because I choose www.example.com as my “main” domain (i.e www.patnotebook.com is my “main” domain).

Bitnami Redirect Instructions 1
Bitnami Redirect Instructions 2

So here’s goes…

Add the following in the httpd-vhosts.conf file for your application. Or, to apply this redirection by default for all applications installed, add it to the default VirtualHost in the /opt/bitnami/apache2/conf/bitnami.conf file.

(1) Locate httpd-vhosts.conf file

Locate httpd-vhosts.conf file
Locate httpd-vhosts.conf file

(2) Make the changes in the file

Make changes to httpd-vhosts.conf file
Make changes to httpd-vhosts.conf file

The final changes look like this:

Setting up SSL for WordPress in Amazon Lightsail
httpd-vhosts.conf file

(3) Locate bitnami-apps-vhosts.conf file

Locate bitnami-apps-vhosts.conf file
Locate bitnami-apps-vhosts.conf file

(4) Make changes to the file bitnami-apps-vhosts.conf

Make changes to the file bitnami-apps-vhosts.conf
Make changes to the file bitnami-apps-vhosts.conf

(5) Restart apache: sudo /opt/bitnami/ctlscript.sh restart apache

restart apache
restart apache

That’s all 🙂

Remember you are making changes at the Apache and Application level to overcome an issue at the domain level.

Share This Article

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.