How to Restrict Addon Domains Folder Accessing from Main Domain in cPanel?

If you are running your websites under cPanel and have addon domains linked with subdomains and your web host provider force to set all the domains inside public_html as below there might be an issue that your addon domain content can be accessed via the main domain as well. – /public_html/domain – /public_html/domain1 – /public_html/domain2

To overcome this issue, you can add the below rule in your .htaccess file. This will prevent Main domain to access the addon domain folder.  If the addon domain folder is accessed through your main domain, it will give the 404 error message.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?$ [NC]
RewriteCond %{REQUEST_URI} ^/domain/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/domain1/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/domain2/(.*)$
RewriteRule ^(.*)$ - [L,R=404]

Was this answer helpful?

« Back


/* */