zoukankan      html  css  js  c++  java
  • 如何防止自己网站的图片被其他网站所盗用,从而导致自己网站流量的损失【apache篇】

    站图片被其他网站盗用的问题我想在业务逻辑代码上解决恐怕是有点困难的。

    而apache上只需要简单的配置就可以解决这个问题。

    解决方法:

    1.确定你的apache加载了mod_setenvif模块(linux下面:grep  "mod_setenvif"  /etc/httpd/conf*/*.conf 查一下,如果有LoadModule mod_setenvif这行说明加载了)

    2.在你服务器根目录配置参数中加入

    <FilesMatch "\.(jpg|jpeg|gif|png)$">
        setEnvIfNoCase Referer "http[s]?://【这里填写你的网站域名】" local_referer=1
        Order Allow,Deny
        Allow from env=local_referer
    </FilesMatch>

    请注意:以上没有任何注释代码

    这里的<Directory></Directory>块代码中的内容是该网站根目录的参数设置,而<FileMatch></FileMatch>代码块中内容是用来配置相应的文件(这里的相应文件是可以用正则表达式匹配的,如图中的"\.(jpg|jpeg|gif|png)$")就是使用正则表单时匹配图片名称)的参数。

    简单参数解答

    setEnvIfNoCase 表示当某参数等于某值时则为变量某变量赋值

    Allow from env=local_referer   表示env=local_referer时允许用户访问该资源

    【本文内容是本人通过学习apache cookbook 第二版实践所得】

  • 相关阅读:
    OSCP Learning Notes Buffer Overflows(3)
    OSCP Learning Notes Buffer Overflows(5)
    OSCP Learning Notes Exploit(3)
    OSCP Learning Notes Exploit(4)
    OSCP Learning Notes Exploit(1)
    OSCP Learning Notes Netcat
    OSCP Learning Notes Buffer Overflows(4)
    OSCP Learning Notes Buffer Overflows(1)
    OSCP Learning Notes Exploit(2)
    C++格式化输出 Learner
  • 原文地址:https://www.cnblogs.com/kiik/p/apache_protect_sources.html
Copyright © 2011-2022 走看看