配置只允许特定的域访问使用的.htaccess特定的文件夹 [英] configure only allow specific domains to access certain folders using .htaccess

查看:333
本文介绍了配置只允许特定的域访问使用的.htaccess特定的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个场景如下:

例如,我有一个网站 http://www.example.com ,我已经建立了几个子域,如 HTTP: //video.example.com http://image1.example.com 的http:// IMAGE2。 example.com 。在Apache中的虚拟主机设置,他们使用的是同一个文件夹(如 /主页/例子/ )。 (这两个领域都使用mod_cband不同的带宽设置)。

For example,I have a website http://www.example.com, and I have setup a few subdomains such as http://video.example.com, http://image1.example.com, http://image2.example.com. In Apache virtual host setting, they are using the same folder (e.g. /home/example/). (these two domains have different bandwidth setup using mod_cband).

我有一个子文件夹 /主页/例子/文件/视频,我想让它只能从子域访问的http://视频.example.com的/文件/视频/ 不过的没有的距离 http://www.example.com/files/videos/ 或任何其他子域。

I have a subfolders /home/example/files/videos, I want to make it only accessible from the subdomain http://video.example.com/files/videos/ but not from http://www.example.com/files/videos/ or any other subdomains.

我怎能配置此与的.htaccess 文件?

推荐答案

将这个code。在 /home/mywebsite/files/videos/.htaccess

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /files/videos/

# if it is not for domain video.mywebsite.com then block it
RewriteCond %{HTTP_HOST} !^video\.mywebsite\.com$ [NC]
RewriteRule ^ - [F]

这篇关于配置只允许特定的域访问使用的.htaccess特定的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆