CPanel Addon Domain Redirect

So you just bought a new domain name but you don’t want to buy another webhosting plan because your current webhosting allowed you to host multiple domain under one account so you decided not to buy another hosting. Although addon domain can be set up easily, but depending on your host configuration especially if they use CPanel and didn’t change where the addondomain location should be placed (in this case the addon domain was placed as a sub-directory in your primary domain when you registered with them), you might know that you can access your addon domain name like below for an example:

And if that’s bothering you, the you can use this .htaccess code. Just make sure to place the .htaccess inside the root of your addon domain directory for example /public_html/addondomainname/.htaccess. And feel free to adjust whether you want www placed in front of your addon domain name or not (assuming that you have configured www in your DNS configuration)

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.addondomain\.com [NC]
RewriteRule ^(.*)$$1 [R=301,L]