This post will show how to use .htaccess to move a website to a new domain, especially when using Bluehost.
A couple of days ago, as I set up this website, jonathanlee.org, I struggled to set up a 301 redirect from my previous domain, jonathanleeonline.com. My hosting is with Bluehost, and they offer a domain redirection tool – but it does not work with addon domains.
Specifically, if I own both oldsite.com and newsite.com, and both are registered with a single bluehost account, oldsite.com is the primary domain, and newsite.com is an add-on domain – and is set up as newsite.oldsite.com (although newsite.com also works). It’s stupid.
But as a result, Bluehost’s regular domain redirection tool and does not work. Technical support tells me I have to modify my .htaccess file, but refuses to give any guidance on how to do so.
I couldn’t find any turn-key solutions via Google searching, so I did some researched, and wrote my own .htaccess solution. And I’m posting the solution online, to help out others.