How to restrict access to Addon Domain through Main Domain so that the contents are not visible from folder view?

How to restrict access to Addon Domain through Main Domain so that the contents are not visible from folder view? [Important| Updated June 2019]

Hello Everyone!!!

Most of our Clients ask us how to hide the Main domain from the URL if anyone wants to access their Addon Domain.

To be more clear let me take an example to brief you, suppose you created any Addon Domain then the actual path of your Addon Domain will be maindomain.com/addon_domain.com because addon_domain.com is literally a directory in your main domain. So now if you want to hide the main_domain from the URL you have to use the htaccess rule to deny URLs starting with /addon_domain.com.

The following htaccess’ code which when applied in the htaccess file inside Addon Directory will generate 404 Error “Page Not Found” if someone wants to access the Addon domain through the Main domain in the URL tab.

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

Just make sure to replace the ‘domain.com’ in the example with your hosting account’s main domain address and ‘addon folder’ with the name of the folder for your Addon domain.

Hope this article helped you.. for more queries and suggestions feel free to write or you can also comment below…

For more information on issues related to your website contact Redserverhost

best linux hosting
cheap Linux hosting

Thanks for Reading!!!

Scroll to Top