homepage Welcome to WebmasterWorld Guest from 54.227.146.68
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

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




msg:4165709
 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




msg:4165776
 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




msg:4165837
 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




msg:4166342
 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