简体   繁体   English

拒绝访问除一个文件夹中的内容以外的所有内容

[英]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.

相关问题 .htaccess-拒绝除一个文件夹之外的所有文件夹 - .htaccess - Deny all except one folder .htacess允许来自本地并拒绝除一个用户代理外的所有用户 - .htacess allow from local and deny all except one user agent Apache - 拒绝访问除 public 之外的所有目录 - Apache - Deny access to all directories except public .htaccess-如何拒绝除一个目录以外的所有目录? - .htaccess - How to deny all directories except one? 拒绝除Apache中的一个配置文件 - Deny all configuration files except one in Apache Apache:如何在主机/.htaccess中仅使用一个.htaccess而不使用httpd.conf的情况下,对目录host / content /应用“命令拒绝,允许所有人拒绝”? - Apache: How to apply 'Order Deny,Allow Deny from all' for directory host/content/ with using only one .htaccess in host/.htaccess, without httpd.conf? 拒绝访问具有给定扩展名的所有文件,除了一个,我该怎么做? - Deny access all files with gived extension except for one, how i do? 从文件夹创建子域,但拒绝文件夹访问 - Create subdomain from a folder, but deny folder access 拒绝访问 .htaccess 中的一个特定文件夹 - Deny access to one specific folder in .htaccess RewriteRule:拒绝除root,文件和特定文件夹中的所有文件以外的所有内容 - RewriteRule: deny everything except root, a file and all files in a specific folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM