[英]Deny access to all content except content from one folder
I want to allow access to only one folder of my site in a given subdomain, and have another subdomain pointing to same documentRoot with full access.我想只允许访问给定子域中我网站的一个文件夹,并让另一个子域指向具有完全访问权限的同一个 documentRoot。 I want this to avoid duplicated urls (for SEO purposes).
我希望这样可以避免重复的网址(出于 SEO 目的)。
In the restricted virtualHost I have this configuration ...在受限制的虚拟主机中,我有这个配置......
<Directory /var/www/secundary.mysite.com/web>
Options -Includes +ExecCGI
AllowOverride All
RewriteEngine On
RewriteCond %{QUERY_STRING} !/bundles.*$ [NC]
RewriteRule ^.*$ - [F]
</Directory>
So I expect that navigation to mysite.com give a forbidden response, but www.mysite.com/bundles/js/script.js returns a normal response.所以我希望导航到 mysite.com 给出禁止响应,但 www.mysite.com/bundles/js/script.js 返回正常响应。
The result is that every request to secundary.mysite.com returns a normal response.结果是对 secundary.mysite.com 的每个请求都返回正常响应。 Am I missing something, or ...?
我错过了什么,还是......?
I have been using a wrong variable.我一直在使用错误的变量。 I wrote %{QUERY_STRING} instead %{REQUEST_URI} that was the variable that I wanted to match again the regular expression.
我写了 %{QUERY_STRING} 而不是 %{REQUEST_URI} 那是我想再次匹配正则表达式的变量。 The correct syntax for my purpose was:
我的目的正确的语法是:
<Directory /var/www/secundary.mysite.com/web>
Options -Includes +ExecCGI
AllowOverride All
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/bundles(.*)$ [NC]
RewriteRule ^.*$ - [F]
</Directory>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.