mod_rewrite help

This is a discussion on mod_rewrite help within the Apache Web Server forums, part of the Web Server and Related Forums category; I'm trying to ban hotlinking from one specific site, and replace the linked images with one telling them not ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-25-2004
colin.
 
Posts: n/a
Default mod_rewrite help

I'm trying to ban hotlinking from one specific site, and replace the linked
images with one telling them not to hotlink from me. This is the contents
of the .htaccess in the document root.

RewriteEngine on

RewriteCond %{HTTP_REFERER} !^http://www\.xxxxxxx\.com/.* [NC]
RewriteCond %{REQUEST_URI}
^/.*\.(gif|jpg|jpeg|png|mpg|mpeg|mp4|mp3|mov|avi|wmv |wmf|rm|ram)$ [NC]
RewriteCond %{REQUEST_URI} !^/dontsteal.jpg$
RewriteRule ^.*$ /dontsteal.jpg [L]

Unfortunately I have a bit of a strange problem. It replaces the images
linked from that site (which is what I want) but bans hotlinking from
everywhere else (which is what I don't want). Is there a way to fix this?
I would really appreciate any help.

Many thanks

Colin


  #2 (permalink)  
Old 09-26-2004
Joachim Ring
 
Posts: n/a
Default Re: mod_rewrite help

> RewriteCond %{HTTP_REFERER} !^http://www\.xxxxxxx\.com/.* [NC]
> RewriteCond %{REQUEST_URI}
> ^/.*\.(gif|jpg|jpeg|png|mpg|mpeg|mp4|mp3|mov|avi|wmv |wmf|rm|ram)$ [NC]
> RewriteCond %{REQUEST_URI} !^/dontsteal.jpg$
> RewriteRule ^.*$ /dontsteal.jpg [L]
>
> Unfortunately I have a bit of a strange problem. It replaces the images
> linked from that site (which is what I want) but bans hotlinking from
> everywhere else (which is what I don't want). Is there a way to fix this?
> I would really appreciate any help.


since there's a ! before ^http://www\.xxxxxxx\.com/.*, you allow it
for www\.xxxxxxx\.com and forbid for anybody else...

you should also think about the fact that many browsers offer a
possibility to suppress the referrer.

joachim
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:56 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0