cpaneladdon-domain

Blocking access to addon domains


I'm using cpanel to create addon domains for my account, the addon domains are created so that addon.com is put in the path /home/user/public_html/addon.com/ which means I can access them via primarydomain.com/addon.com. I'd like to cut off access to these directories so people can't access them outside of their domain


Solution

  • Add the following code in your .htaccess file at the root of addon.com

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(.*)\.primarydomain\.com$
    RewriteRule ^(.*)$ path/to/404/ErrorDoc
    

    Alternative and far better: while creating addon.com specify the document root as outside the public_html folder. ie. /addon.com instead of /public_html/addon.com.

    Hope that helps.