.htaccess中设置防盗链方法

在网站根目录找到 .htaccess文件,下载到本地,添加以下代码,上传覆盖

记得在网站根目录下设置一个404.html错误页面

请将下面的域名(www.baidu.com,baidu.com)替换成您的网站域名

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://baidu.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://baidu.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.baidu.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.baidu.com$ [NC]
RewriteRule .*\.(gif|jpg|jpeg|png|bmp|swf|mp3|wav|zip|rar)$ http://www.baidu.com/404.html [R,NC]