I'm using cpanel to create addon domains for my account, the addon domains are开发者_JAVA百科 created so that addon.com
is put in the path /home/user/public_html/addon.com/
which means I can access them via primarydomain.com/addon.com
. I'd like to cut off access to these directories so people can't access them outside of their domain
Add the following code in your .htaccess file at the root of addon.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.primarydomain\.com$
RewriteRule ^(.*)$ path/to/404/ErrorDoc
Alternative and far better: while creating addon.com specify the document root as outside the public_html folder. ie. /addon.com instead of /public_html/addon.com.
Hope that helps.
use htaccess and look at hostname and redirect if it wrong
精彩评论