Forum Moderators: phranque

Message Too Old, No Replies

Hotlinking: How to allow Facebook to post images from your site

I cannot find a way to do it!

         

karkadan

1:47 am on Feb 23, 2011 (gmt 0)

10+ Year Member



Hi!

I am using hotlinking protection. It has worked fine until I found out my images are not appearing on facebook.

I use Facebook to promote certain news, and it always looked neat when images follow the messages. Since the hotlinking protection is on, images do not appear.

I have tried allowing facebook.com and external.ak.fbcdn.net but doesnt work.

I have searched this site and Bing and Google for answers, and I don't find any.

Can someone help?

wilderness

3:29 am on Feb 23, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You just add an exception to your hot-link rule.
The leading exclamation means "except".

I've no clue if this the correct URL for facebook?

RewriteCond %{HTTP_REFERER} !^http://www\.FaceBook\.com/

karkadan

4:05 am on Feb 23, 2011 (gmt 0)

10+ Year Member



Yes, I have already created 2 exceptions.
www.facebook.com
and
external.ak.fbcdn.net (this address is used by facebook for redirections and for loading images into facebook, apparently).

My question is not so much how to write the code in Apache, but to know how to create an exception for Facebook (addresses in this case).

wilderness

5:13 am on Feb 23, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



external.ak.fbcdn.net (this address is used by facebook for redirections and for loading images into facebook, apparently).


You mean your raw logs show referrals from external.ak.fbcdn.net

Your not able to manipulate facebooks server, only your own.

If an IP range or referral doesn't show in a page or image request or UA than there's not any action you take to route that request.

wilderness

6:19 am on Feb 23, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



RewriteCond %{REMOTE_ADDR} !^123\.456\.789\. [OR]
RewriteCond %{REMOTE_ADDR} !^123\.455\.([0-9]|[1-9][0-9]|1[01][0-9])\.

Please note; these IP ranges are insignificant and merely random.

jdMorgan

6:43 pm on Mar 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The rewritecond that wilderness posted above must be added to your currently-existing hotlink protection code.

If you did not write/create/copy that anti-hotlink code in your .htaccess file, but rather used a "control panel" to invoke it, then you'll need to turn off the control panel anti-hotlinking code and put your own code into your .htaccess file. Typically:

RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^https?://www\.example\.com/
RewriteCode %{HTTP_REFERER} !^https?://(www\.)?facebook\.com/
RewriteRule \.(gif|jpe?g|png|ico|css|js|mp3|flv|swf|mp4|wav)$ - [F]

The filetypes listed in the RewriteRule pattern are just examples. List the specific filetypes that you want to protect on your site. Put the most-frequently-requested filetypes first in the list.

This also assumes that your canonical domain name is "www.example.com". If not, adjust to suit.

Jim

londrum

6:51 pm on Mar 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



ive got a facebook application that includes thumbnails of various events, and facebook seems to be a problem with the size of the images.
my small thumbnails display every time, but the slightly larger ones (no more than 20 pixels extra each way) do not appear. maybe you are having the same problem. keep the same filename, but reduce the dimensions and see if it works.
i would love if someone has a fix for this.