Welcome to WebmasterWorld Guest from 54.196.212.62

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

.htaccess redirect not working for me.

     

georgeek

11:22 am on Jul 7, 2010 (gmt 0)

10+ Year Member



I have Rewrite rules in my .htaccess that work, for example www to non-www and one Rewrite rule that doesn't work:

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?blogspot\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?myspace\.com/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?coldlink\.com/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?habrahabr\.ru/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?facebook\.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpg|jpeg|png|gif|bmp)$ http://mydomain.com/images/hotlinked.gif [NC,R,L]


When I put this into my .htaccess the hotlinking images are no longer displayed on the infringing sites but the intended substitute hotlinked.gif is not displayed either.

Any suggestions as to why this may be?

georgeek

1:36 pm on Jul 7, 2010 (gmt 0)

10+ Year Member



Ah! Solved it! hotlinked.gif was causing some kind of loop because it is a .gif

I changed the name of the file to hotlinked.giff on the server and in .htaccess, now it works as it should.

g1smd

3:11 pm on Jul 7, 2010 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



The better way is to exclude that file by adding another RewriteCond (with a negative match for the filname), otherwise you're serving a GIFF file to a browser, and it might not know what to do with it.

georgeek

6:38 am on Jul 8, 2010 (gmt 0)

10+ Year Member



Thanks g1smd that sounds like a good idea but composing RewriteCond's is out of my league, can you point me in the right direction please?

I have a followup...

One of the sites that is hotlinking is on Google sites [sites.google.com...]

Would this work?

RewriteCond %{HTTP_REFERER} ^http://(.+\.)?sites.google\.com/.*$ [NC,OR]


I am really worried about including all Google by mistake!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month