0

I have already protected images for hotlinking, but I can't grant access to facebook bot. The configuration in my htaccess is:

#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]

Well the probles is when I try to limit the user-agent to facebook, this doesn't work and the open graph api can get the images. Thanks!

1
  • if this is usesful for someone: RewriteCond %{HTTP_USER_AGENT} !facebookexternalhit\/1\.1\ (\+http:\/\/www\.facebook\.com\/externalhit_uatext\.php) Dec 14, 2017 at 19:13

1 Answer 1

0

Try to change the RewriteCond %{HTTP_USER_AGENT}line to:

RewriteCond %{HTTP_USER_AGENT} !(?:facebookexternalhit|Facebot) [NC]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.