[CentOS] httpd .htaccess rewrite for images

Dave dave.mehler at gmail.com
Tue Aug 18 01:49:45 UTC 2009

	I'm running httpd on a Centos 5.3 machine. I'm trying to use
.htaccess to disable direct linking to site images. I've got the following
rewrite rule, the domain is test.example.com which is at
/var/www/test.example.com under which is a directory called images.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(test\.)?example.com/.*$ [NC]
RewriteRule \.(jpg|gif)$ - [F]

In my httpd virtual host directive i have:

alias /images "/var/www/test.example.com/images"
<Directory "/var/www/test.example.com/images">
Options None
AllowOverride None
order allow,deny
Allow from all

Comments appreciated.

More information about the CentOS mailing list