獨立ip主機設(shè)置防盜鏈(適用vps云主機服務(wù)器)apache實現(xiàn)防盜鏈: 添加到.htaccess 文件中 RewriteCond %{HTTP_REFERER} !baidu.com [NC] RewriteCond %{HTTP_REFERER} !google.com [NC] RewriteCond %{HTTP_REFERER} !xxx.net [NC] RewriteRule .*\.(jpg|jpeg|png|gif|bmp|swf|mp4|mp3|zip|rar|pdf|webp|js|css)$ /band.txt [NC,L] iis6實現(xiàn)防盜鏈:
進入others/httpd.conf中,保留前兩行,復(fù)制以下規(guī)則保存即可 RewriteEngine on RewriteCond %{HTTP_REFERER} !baidu.com [NC] RewriteCond %{HTTP_REFERER} !google.com [NC] RewriteCond %{HTTP_REFERER} !xxx.net [NC] RewriteRule .*\.(jpg|jpeg|png|gif|bmp|swf|mp4|mp3|zip|rar|pdf|webp|js|css)$ /band.txt [NC,L] xxx.net是您自己的域名 band.txt是被盜鏈后的提示內(nèi)容文件 iis7+實現(xiàn)防盜鏈: 使用url-rewrite模塊實現(xiàn),模塊下載地址 https://www.iis.net/downloads/microsoft/url-rewrite 在網(wǎng)站根目錄wwwroot下創(chuàng)建一個web.config文件,復(fù)制以下代碼保存即可, 如果網(wǎng)站有設(shè)置偽靜態(tài),已存在web.config,則只復(fù)制中間顏色部分代碼,加到第一個<rules>之后即可 <?xml version="1.0" ?> <configuration> <rule name="Prevent hotlinking"> <match url="^.*\.(jpg|jpeg|png|gif|bmp|swf|mp4|mp3|zip|rar|pdf|webp|js|css)$" ignoreCase="true" /> <conditions> <add input="{HTTP_REFERER}" pattern="http://www.xxxxxx.com/.*" negate="true" /> <add input="{HTTP_REFERER}" pattern="http://xxxxxx.com/.*" negate="true" /> </conditions> <action type="Rewrite" url="/404.html" /> </rule> </rules> nginx實現(xiàn)防盜鏈: 參考添加靜態(tài)文件的location配置 server { listen 80; server_name www.yoursite.com; # 定位到圖片等靜態(tài)資源 location ~ .*\.(jpg|jpeg|png|gif|bmp|swf|mp4|mp3|zip|rar|pdf|webp|js|css)$ { expires 30d; access_log /dev/null; valid_referers *.yoursite.com yoursite.com; if ($invalid_referer){ return 444; } } } 相關(guān)產(chǎn)品: 異常流量清洗服務(wù)產(chǎn)品介紹
|
|||||
| >> 相關(guān)文章 | |||||
|
|
|||||
400-028-5800
028-62778877
您好,非正常上班時間若有緊急技術(shù)問題,請撥總機后按7號鍵, 其他問題請?zhí)峤还位蛟谏习鄷r間聯(lián)系,謝謝支持!