0

Possible Duplicate:
Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?

there is this domain that is hotlinking my css files. This is an example in the log:

[Thu Jul 14 15:17:14 2011] [error] [client 190.79.200.109] File does not exist: /www/old.css, referer: http://www.somedomain.com/start.php

I want to redirect all non-existant files that come from that somedomain.com domain to another url so they stop doing that. How do i do that via htaccess?

Andres SK
  • 228
  • 3
  • 7
  • 21

1 Answers1

2

This is easy to do using mod_rewrite:

This code should be placed in the htaccess file in the image directory you wish to protect.

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    Options +Indexes
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !domain.com
    RewriteRule \.(gif|jpg|jpeg|png)$ nosteal.jpg [L]
</IfModule>
Handyman5
  • 5,177
  • 25
  • 30