Forum Moderators: phranque

Message Too Old, No Replies

Hotlinking prevention code stopped working

Any idea why this code no longer works?

         

beggers

7:57 am on Oct 14, 2005 (gmt 0)

10+ Year Member



I've run this anti-hotlinking code on all my sites for years but somewhere along the line it stopped working. I'm on Apache/Linux. This code is so simple that something must have changed in the syntax that prevents it from working:

RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mysite1.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mysite2.com(/)?.*$ [NC]
RewriteRule .*\.(gif¦jpg¦jpeg¦bmp)$ http://www.mysite2.com/theft/anti_theft_image.gif [R,NC]

Basically it just lets mysite1 and mysite2 hotlink to the images. If any other site attempts to hotlink it subsitutes the anti_theft_image.gif .

Someone also suggested that it might be a firewall that's changing the value of {HTTP_REFERER} to some proprietary value. What do you think?

theanimalusa

1:30 pm on Oct 14, 2005 (gmt 0)



Your site host probably updated Apache or made some configuration changes. [Try a search for .htaccess generator or hotlinking wizard.]

Good luck, Dave

[edited by: jdMorgan at 4:15 pm (utc) on Oct. 14, 2005]
[edit reason] No URLs, please. See TOS. [/edit]

jdMorgan

4:31 pm on Oct 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If the code was working and stopped, then that means that the host changed your configuration.

Do you have any other still-working mod_rewrite code, or any other working .htacess code of any kind?

Some simple tests would be in order to find out if you can still use .htaccess at all, or if mod_rewrite has been disabled. Your code is not pretty, but it should work as-is.

Jim

beggers

4:45 pm on Oct 14, 2005 (gmt 0)

10+ Year Member



The server does support mod_rewrite and it is enabled (I use it on some Amazon affiliate sites). This is the only .htaccess code that fails. I've tried several other versions of this and none work.

I'm hoping that someone here has had this specific problem and knows the solution.