Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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] File does not exist: /www/old.css, referer:

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

share|improve this question

marked as duplicate by Shane Madden, Lucas Kauffman, Ward, Michael Hampton, Ladadadada Sep 5 '12 at 20:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 2 down vote accepted

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} !
    RewriteRule \.(gif|jpg|jpeg|png)$ nosteal.jpg [L]
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.