apache 防盗链的第一种实现方法,可以用 rewrite 实现。 首先要确认 apache 的 rewrite module 可用:能够控制 apache httpd.conf 文件的,打开 httpd.conf,确保有这么一行配置: loadmodule rewrite_module modules/mod_rewrite.so<VirtualHost *:80> #加在这个下面 CustomLog "-----------" combined RewriteEngine On #RewriteCond %{HTTP_REFERER} !^$ [NC] RewriteCond %{HTTP_REFERER} !^https://.*.hak.red/.*$ [NC] RewriteCond %{HTTP_REFERER} !^https://.*.hak.red$ [NC] RewriteRule .*\.(gif|jpg|swf|css|js|png|ico)$ http://error.hak.red/ [R,NC] #只允许 *.hak
Hawk
别固执的认为某事必须 !