網(wǎng)站防盜鏈的方法
來源:程序員人生 發(fā)布時間:2015-07-23 14:09:23 閱讀次數(shù):5145次
最近這個程序員人生網(wǎng)站接到用戶投訴,說非常卡,按道理說不應該呀,網(wǎng)站流量一般,配置還可以,不應該卡。最后經(jīng)過排查,是網(wǎng)站圖片遭到了盜鏈。
現(xiàn)在針對apache服務器做個如何防止盜鏈
第一步:對配置文件進行修改httpd.conf
#LoadModule rewrite_module modules/mod_rewrite.so
#Include conf/extra/httpd-vhosts.conf
將兩處的#號去掉
第二步,配置httpd-vhosts.conf文件
文件位置一般在Apache\conf\extra\下面
例如下面是配置程序員人生網(wǎng)站代碼,大家依葫蘆畫瓢配置就可以啦
-
- ServerAdmin webmaster@dummy-host2.example.com
- DocumentRoot "C:\www\wfuyu"
- ServerName www.vxbq.cn
- ErrorLog "logs/www.vxbq.cn-error.log"
- CustomLog "logs/www.vxbq.cn-access.log" common
-
- RewriteEngine On
- RewriteCond %{HTTP_REFERER} !^http:
- RewriteCond %{HTTP_REFERER} !^http:
- RewriteCond %{HTTP_REFERER} !^http:
- RewriteCond %{HTTP_REFERER} !^http:
- RewriteRule .*\.(gif|jpg|jpeg|png|js|css|swf)$ [R,NC]
-
這樣配置后,通過外網(wǎng)就不能訪問網(wǎng)站資源啦
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學習有所幫助,可以手機掃描二維碼進行捐贈