2013-03-05 55 views
0

文件夹层次的.htaccess:具体路径允许所有其他被拒绝

/html => maindomain.com 
/html/_subdomain => subdomain.maindomain.com 
/html/_subdomain/anotherdomain => anotherdomain.com and subdomain.maindomain.com/anotherdomain 
/html/_subdomain/anotherdomain/admin => anotherdomain.com/admin and subdomain.maindomain.com/anotherdomain/admin 

我要找的.htaccess代码以拒绝“anotherdomain.com/admin”,让“subdomain.maindomain.com/anotherdomain/admin”只为这个文件夹。 我的代码

<Directory /html/subdomain/anotherdomain/admin> 
Order Deny,Allow 
Deny from all 
Allow from subdomain.maindomain.com/anotherdomain/admin 
</Directory> 

回答

0

您不能使用<Directory>容器中的htaccess文件中。里面的/html/_subdomain/anotherdomain/admin目录中的htaccess文件,尝试:

RewriteEngine On 
RewriteCond %{HTTP_HOST} !^subdomain.maindomain.com$ [NC] 
RewriteRule^- [L,F] 

所以,如果访问不是从主机subdomain.maindomain.com,然后在403请求结果被禁止的。