Forum Moderators: phranque

Message Too Old, No Replies

Possible solution to hotlinking problem

         

ReFredzRate

8:16 am on May 7, 2004 (gmt 0)

10+ Year Member



I've just registered here, so please be nice ;)

I've seen quite some hotlinking problems occur with htaccess files. Mostly this one: When I upload the htaccess file to my webhost server, and I create a simple HTML file calling a picture, the picture DOES get displayed.

I've been playing around this problem for the past three or four days, and I think I may have come up with quite a nice solution.

In this topic [webmasterworld.com] there is a hotlinking problem as well.

The htaccess file has this content:

RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://216\.239.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://images\.google.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www\.google\..*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://translate\.google\..*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://babel\.altavista\..*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://babelfish\.altavista\..*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://world\.altavista\.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www\.excite\.co.*$ [NC]
RewriteRule \.(jpg¦JPG)$ [mydomain.com...] [R,L]

I've been googling and playing around with the source itself for some hours, and it seems that the following rule in the source makes it possible to view the files anyway.

RewriteCond %{HTTP_REFERER}!^$

This is the rule I removed from my htaccess file and it seems that it works pretty nice now.

ReFredzRate

1:57 pm on May 7, 2004 (gmt 0)

10+ Year Member



Alright, a little update on this matter.

The line I removed actually has to be in the htaccess file. When removed some firewalls may block viewing of the images when visiting a website.

A friend of mine was not able to view the images on my website, so I had to put back in the removed line to restore that error.

But anyway, hotlinking got a bit clearer for me! ^_^