Forum Moderators: phranque

Message Too Old, No Replies

.htaccess hot link prevention issues

Want to allow it for some sites, but not working

         

whats up skip

3:02 am on Aug 3, 2009 (gmt 0)

10+ Year Member



I have had to implement hot linking prevention on my main site to slow down this problem, but I am now having some problems with allowing the images to show up on some sites. I could really do with some help on this one.

Here is a section of the .htaccess from the root directory of mysite.com.au (not the real name, nor badimages)

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite.com.au/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?google.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?maps.google.com.au/.*$ [NC]
RewriteRule .*\.(jpg¦jpeg¦png)$ [badimages.com...] [R,NC]

mysite.com.au is the primary site where the images are stored.

maps.google.com.au and the other google domains are some of the other sites I wish to allow to have hot links working on, but they don't seem to work and just show my warning image.

See example
[maps.google.com.au...]

Then select "Imperial Palace East Garden" to see if the picture shows.

wilderness

2:40 pm on Aug 3, 2009 (gmt 0)

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



There are many, many old threads on hotlinking [google.com] or hot linking [google.com]

whats up skip

8:57 pm on Aug 3, 2009 (gmt 0)

10+ Year Member



Are you suggesting I should have posted this in one of the old threads?

wilderness

9:26 pm on Aug 3, 2009 (gmt 0)

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



I'm suggesting you use those previously discussed many times examples (such as this with comment by Jim [webmasterworld.com]) to correct your attempt.

whats up skip

12:19 am on Aug 4, 2009 (gmt 0)

10+ Year Member



I had read many of the threads on this forum and on many other sites and forum, but I still seems to be having problems.

I have reviewed the specific thread you mentioned and I have tried the suggestions there, but it has not resolved my problem.

Now the issue may relate to a specific issue with Google Maps, as I have no problems on most other sites, or it could be something more general.

wilderness

1:19 am on Aug 4, 2009 (gmt 0)

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



The following has been provided over and over, time and time again, and in many of the links and/or previous threads that were contained within the search results.

A general google on inline linking will provide similar htaccess examples [google.com]

Redirecting to an alternative image is a BAD practice. The result is either you provide information to visitors unnecessarily, and even antagonize the visitor into looking for other weaknesses.

maps.google is NOT a www.

Your lines offered numerous errors of unescaped DOTS.

Mysites utilize different image types than yours.

RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite\.com\.au [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.google.com [NC]
RewriteCond %{HTTP_REFERER} !^http://maps\.google.com\.au [NC]
RewriteRule \.(jpg¦gif¦pdf¦ico)$ - [NC,F]

Please note; pipe characters require correction as they are broken by the forum format.

wilderness

2:45 am on Aug 4, 2009 (gmt 0)

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



Your lines offered numerous errors of unescaped DOTS.

RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite\.com\.au [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.google.com [NC]
RewriteCond %{HTTP_REFERER} !^http://maps\.google.com\.au [NC]
RewriteRule \.(jpg¦gif¦pdf¦ico)$ - [NC,F]

As do my own. (edit time expired)

Corrected:

RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite\.com\.au [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.google\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://maps\.google\.com\.au [NC]
RewriteRule \.(jpg¦gif¦pdf¦ico)$ - [NC,F]

jdMorgan

2:42 pm on Aug 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't see anything 'fatally-wrong' with the originally-posted code, even if it's not optimal. Basically, the original code should work, as long as you're not getting fooled by browser caching issues (flush your browser cache completely between every test).

I would suggest re-typing the code using a plain-text editor (such as Windows NotePad), in case there are any 'hidden' characters or characters using alternate-encoding schemes not recognized by *nix/Apache.

Replacing images with a 'promotional image' is an acceptable practice, but of course you want it to work properly... :)

Jim