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 htaccess rule to deny urls starting with /addon_domain.com.

The following htaccess’ code which when applied in htaccess file inside Addon Directory will generate 404 Error “Page Not Found” if someone wants to access Addon domain through 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 ‘addonfolder’ 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!!!