RewriteEngine on RewriteCond %{HTTP_REFERER} !ot.com [NC] RewriteCond %{HTTP_REFERER} !baidu.com [NC] RewriteCond %{HTTP_REFERER} !soso.com [NC] RewriteCond %{HTTP_REFERER} !google.com [NC] RewriteCond %{HTTP_REFERER} !sogou.com [NC] RewriteCond %{HTTP_REFERER} !youdan.com [NC] RewriteCond %{HTTP_REFERER} !yahoo.cn [NC] RewriteCond %{REQUEST_URI} !logo.png [NC] RewriteRule .*\.(jpg|png|gif|jpeg)$ http://www.ot.com/logo.png [R,NC,L]
假設我本身的域名是 www.ot.com,兩關鍵的地方:google
1)!ot.com ,http_referer(來源) 非 ot.com 域名訪問時重寫;spa
2)!logo.png ,request_uri(連接) 非 logo.png 圖片時重寫,若是這個圖也重寫的話,會變成死循環的!!!code