Mobile app version of vmapp.org
Login or Join
Candy875

: How do I prevent access to an add-on domain's root directory from main hosting domain name I have an add-on domain in my cPanel website. The root directory for it is under the root of the

@Candy875

Posted in: #Cpanel #Domains

I have an add-on domain in my cPanel website. The root directory for it is under the root of the hosting. How can I prevent access through the main domain?

For example, addondomain.com is configured to serve up files from public_html/addondomdain. How do I prevent people seeing the files at maindomain.com/addondomain and only when viewing them at addondomain.com?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Candy875

2 Comments

Sorted by latest first Latest Oldest Best

 

@Cody1181609

This rewrite rule (in public_html/addondomain/.htaccess) will handle redirection for you, should a visitor land at a domain.com/addondomain/ path:

RewriteEngine on
RewriteCond %{HTTP_HOST} !addondomain.com$
RewriteRule [addondomain]?(.*) www.addondomain.com/ [R=301,L]


The rewrite condition instructs mod_rewrite to match on requests where the requested domain name does not end in "addondomain.com" (to include the primary domain and all its subdomains) and the rule instructs mod_rewrite to remove the addondomain subdirectory from the request path (if it appears) and direct the user to the add-on domain name.

10% popularity Vote Up Vote Down


 

@Heady270

There is no way to hide the addon domain subfolder on your root domain, as it is literally a directory on your website root. You can use an htaccess rule to prevent people accessing it, or you can simply forward it to the subdomain.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme