Apache设置防盗链

盗链,就是盗取链接,假如我们的网站有很多好看的图片,别人可以查看我们网站图片的链接,然后应用在他的网站上,这样的话,去访问他的网站,实际上消耗的是我们的流量(因为实际链接在我们这里),这样我们就不得不去配置防盗链,使得别人不能复制我们图片的链接。

[root@localhost ~]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf 
<VirtualHost *:80>
    DocumentRoot "/data/www"
    ServerName www.test.com
    ErrorLog "logs/test.com_error_log"
    CustomLog "logs/test.com_access_log" combined
    SetEnvIfNoCase Referer "^http://.*\.test\.com" local_ref    # 表示只有 test.com 和 abc.com 的访问才允许,其他的都拒绝
    SetEnvIfNoCase Referer ".*\. abc\.com" local_ref
    <filesmatch "\.(txt|doc|mp3|zip|rar|jpg|gif|png)">
        Order Allow,Deny
        Allow from env=local_ref
        Deny from all
    </filesmatch>
</VirtualHost>

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.