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.


example.com – /public_html/domain
example1.com – /public_html/domain1
example2.com – /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.)?maindomain.com$ [NC]
RewriteCond %{REQUEST_URI} ^/domain/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/domain1/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/domain2/(.*)$
RewriteRule ^(.*)$ - [L,R=404]

Related Articles

How to set the cron job to run a PHP script in cPanel?

This article will help how to setup cron job for a PHP file in cPanel What is Cron? Cron is a...

Shell script to change multiple cPanel account password.

You may need to change the password of all your cPanel account in case of a potential security...

How to install Oscommerce manually in cPanel ?

Oscommerce is an open-source script. You can host the OsCommerce on cPanel or another hosting...

How To Automatically Delete Forwarded Mails in cPanel?

You can use cPanel email forwarder option to forward your emails to any other email account....

How to fix RVsitebuilder error : decode_json failed, invalid json. error: garbage after JSON object, at character offset 216

You may receive the below error while configuring the website using the RVsitebuilder in cPanel....

  • 0 Users Found This Useful

Was this answer helpful?