homepage Welcome to WebmasterWorld Guest from 54.237.98.229
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
.htaccess redirect not working for me.
georgeek

10+ Year Member



 
Msg#: 4165707 posted 11:22 am on Jul 7, 2010 (gmt 0)

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

10+ Year Member



 
Msg#: 4165707 posted 1:36 pm on Jul 7, 2010 (gmt 0)

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

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4165707 posted 3:11 pm on Jul 7, 2010 (gmt 0)

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

10+ Year Member



 
Msg#: 4165707 posted 6:38 am on Jul 8, 2010 (gmt 0)

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!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved