文件夹层次结构
/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 :(得分:0)
您不能在htaccess文件中使用<Directory>
容器。在/html/_subdomain/anotherdomain/admin
目录中的htaccess文件中,尝试:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^subdomain.maindomain.com$ [NC]
RewriteRule ^ - [L,F]
因此,如果访问权限不是来自主机 subdomain.maindomain.com ,则请求会导致403被禁止。