: 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
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?
More posts by @Candy875
2 Comments
Sorted by latest first Latest Oldest Best
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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.