Knowledgebase

Restrict subdomain access to addon domains

Portal Home > Knowledgebase > cPanel - Control Panel > Restrict subdomain access to addon domains

Each Addon Domain requires a subdomain. Using mod_rewrite you can stop people from being able to use the addon domain as a subdomain of the primary domain

Preventing use of the Subdomain

Put this in the .htaccess file located at the subdomains folder, changing the subdomainprimarydomain.com and addondomain.com:

RewriteEngine On
            RewriteCond %{HTTP_HOST} ^subdomain.primarydomain.com$ [OR]
            RewriteCond %{HTTP_HOST} ^www.subdomain.primarydomain.com$ [OR]
            RewriteCond %{HTTP_HOST} ^addondomain.com$
            RewriteCond %{REQUEST_URI} ^/$
            RewriteRule ^(.*)$ http://www.addondomain.com/ [R=301,L]

subdomain, cpanel hosting

Was this answer helpful?
40 Users Found This Useful 40 Votes

Also Read