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]
  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to migrate the cPanel account to the DirectAdmin Panel?

As we know cPanel increased their pricing and now they are charging based on each cPanel account....

What are the differecnce between Sub-Domain, Parked Domain And An Add-on Domain?

SubDomain You can add additional sections to your main domain as a sub-domain. This will help to...

How to install Moodle using Softaculous in cPanel?

You need to have PHP extension fileinfo enabled for your domain and PHP version equal to or...

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 get SPF, DKIM and PTR Record for Email Deliverability from cPanel?

Email Deliverability is a useful cPanel feature to prevent your emails from being marked as spam...