前提Apache中的mod_rewrite模塊為激活狀態(tài),既然要消滅掉mp3文件的盜鏈就順便也把圖片盜鏈的設(shè)置給做了,下面是我在網(wǎng)站根目錄的.htaccess文件中的配置,供同病相憐之人參考:。
- #開啟mod_rewrite引擎
- RewriteEngineOn
- #設(shè)置合法請(qǐng)求源
- RewriteCond%{HTTP_REFERER}!^$[NC]
- RewriteCond%{HTTP_REFERER}!zhangzhang.net[NC]
- RewriteCond%{HTTP_REFERER}!google.com[NC]
- RewriteCond%{HTTP_REFERER}!baidu.com[NC]
- RewriteCond%{HTTP_REFERER}!yahoo.com[NC]
- RewriteCond%{HTTP_REFERER}!msn.com[NC]
- RewriteCond%{HTTP_REFERER}!bloglines.com[NC]
- RewriteCond%{HTTP_REFERER}!feedburner.com[NC]
- RewriteCond%{HTTP_REFERER}!feedsky.com[NC]
- #指向警告頁面
- RewriteRule.*.(gif|jpg|png|mp3)$outlink.gif[L,NC]