Forum Moderators: phranque
"GET /drawing/user-name/draw123.jpg HTTP/1.1" 302 307 "http://chat9.terra.com.br:23137/xx?ImagensDiversos&Diversos+1&VANONIMO___&-1&97c6a5e241019e19124e1805a831c" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; MSN 9.0; MSNbMSNI; MSNmen-us; MSNcOTH)"
So it's not blocking the image because of the 302, right?
This is what I have in the httpd.conf file:
<Directory "/home/site/mysite/drawing">
Options -Indexes
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mysite\.com [NC]
RewriteRule \.(jpg)$ [127.0.0.1...] [R,NC]
RewriteCond %{HTTP_USER_AGENT} ^HTTrack [OR]
RewriteCond %{HTTP_REFERER} ^http://chat9\.terra\.com\.br [NC,OR]
RewriteCond %{REMOTE_ADDR} ^84\.128\.6\.37
RewriteRule!404\.php$ - [F]
</Directory>
What am I doing wrong? Thanks.
> So it's not blocking the image because of the 302, right?
Possibly...
You don't need a redirect unless your substitute image is not on this server. Try an internal rewrite instead of a redirect:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite\.com [NC]
RewriteRule \.jpg$ /drawing/stuff/logo.gif [NC,L]
The [L] flag will stop mod_rewrite processing if the rule matches and the rewrite is invoked. There is usually no need for further mod_rewrite processing, so use [L] unless you have a reason not to use it. The [F], [G], and [P] flags all include an implied [L], so you don't need it there (such as in your second rule).
Another likely cause of trouble is that the requested image may already be stored in your browser cache. Therefore, the request is never sent to your server, so your code cannot have any effect. Be sure to flush your browser cache before testing any new rewrite or redirect code. Otherwise, you will get unexpected results.
Jim