我已经保护图像以进行热链接,但我可以授予访问facebook bot的权限。我的htaccess中的配置是:
#Prevent hotlinking
RewriteEngine on
#allows you to specify which files this applies to
RewriteCond %{REQUEST_FILENAME} \.(?:js|css|gif|png|jpg)$
#if the client's (server's) IP address is not this
RewriteCond %{REMOTE_ADDR} !^0\.0\.0\.0$
RewriteCond %{HTTP_REFERER} !^http?://www\.my\.domains\.mx/
RewriteCond %{HTTP_USER_AGENT} !="facebookexternalhit/1.1|facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)|Facebot"
# forbid access
#RewriteRule .* - [F,L]
问题是,当我尝试将用户代理限制到Facebook时,这不起作用,而开放图形api可以获取图像。谢谢!
答案 0 :(得分:0)
尝试将RewriteCond %{HTTP_USER_AGENT}
行更改为:
RewriteCond %{HTTP_USER_AGENT} !(?:facebookexternalhit|Facebot) [NC]