Cpanel Addon Domains Without Subdomains

Making Cpanel Addon Domain Without Subdomain

Add on domains are a great asset to any web developer. When you have a hosting account you often have the option to have many or unlimited addon domains on one account.In most aspects, it is a great value for your buck. However, there are some differences that must be noted about addon domains. An addon domain gets made as a subdomain. You may see that the new site example.com shows up in the browser just like the main domain, and an added subdomain shows as subdomain.example.com. But, a page on the addon domain can be viewed as example.mainsite.com/mypage.html. Although this looks innocent, it can cause some of the urls of the addon domain to rank higher on Google than the actual subdomain. To solve the issue of urls shoing up as a potential subdomain or actual url, the codes below can be added to the htaccess file so your site cannot be access through the subdomain.

Web Templates

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTP_HOST} mainsite\.com$
RewriteRule ^(.*)$ "http\:\/\/www.addondomain\.com\/" [R=301,L]

</IfModule>

WordPress

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTP_HOST} mainsite\.com$
RewriteRule ^(.*)$ "http\:\/\/www.addondomain\.com\/" [R=301,L]

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

Joomla

########## Begin - Joomla! core SEF Section
#

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteCond %{HTTP_HOST} websitebc\.com$
RewriteRule ^(.*)$ "http\:\/\/www.example\.com\/" [R=301,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
#
########## End - Joomla! core SEF Section