首页>>帮助中心>>香港美国VPS云主机apache、iis6、ii7设置防盗链

香港美国VPS云主机apache、iis6、ii7设置防盗链

2023/4/7 601次
  1. 香港美国VPS云主机有许多的系统,客户可以根据自己的需求来选择对应的系统。

  2. 若是纯净版系统,请按https://www.enuoidc.com/help/1274.html 把伪静态组件开启

    然后在配置文件中按以下系统规则配置


apache和iis6实现防盗链规则相同:


进入others/httpd.conf中,保留前两行,复制以下规则保存即可

RewriteEngine on

RewriteCond %{HTTP_REFERER} !baidu.com [NC]

RewriteCond %{HTTP_REFERER} !google.com [NC]

RewriteCond %{HTTP_REFERER} !xxx.net [NC]

RewriteCond %{HTTP_REFERER} !^$ [NC]

RewriteRule .*\.(gif|jpg)$ /band.txt [NC,L]


xxx.net是您自己的域名

band.txt是被盗链后的提示内容文件


iis7实现防盗链:


在网站根目录wwwroot下创建一个web.config文件,复制以下代码保存即可, 如果网站有设置伪静态,已存在web.config,则只复制中间颜色部分代码,加到第一个<rules>之后即可

<?xml version="1.0" ?>

<configuration>
<system.webServer>
<rewrite>
<rules>

<rule name="Prevent hotlinking">

<match url="^.*\.(rar|zip|jpg|gif)$" ignoreCase="true" />

<conditions>

<add input="{HTTP_REFERER}" pattern="http://www.xxxxxx.com/.*" negate="true" />

<add input="{HTTP_REFERER}" pattern="http://xxxxxx.com/.*" negate="true" />

<add input="{HTTP_REFERER}" pattern="^$" negate="true" />

</conditions>

<action type="Rewrite" url="/404.html" />

</rule>

</rules>
</rewrite>
</system.webServer>
</configuration>