Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

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.

1 Answer 1

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

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