.htaccess files are a very powerful tool of the Apache web server, but complicated to get working. They are used on this site to rewrite the urls into reader friendly names instead of the php=5&….that lies underneath. They also control access to your files. In this case I’m using the .htaccess file to stop people from linking to my images, movies, audio, and flash to use on their site. This doesn’t stop people from linking to my pages, which I’d like them to do early and often.
A lovely thing about .htaccess files: if you place them in a directory, the conditions and permissions you set up affect all subfolders of that folder. So, if you want to protect all your images, just drop a single .htaccess file in your main images directory, and all subfolders are taken care of.
Here’s the code that I’m using for my .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://www.buzolich.com [NC]
RewriteCond %{HTTP_REFERER} !^http://buzolich.com [NC]
RewriteRule [^/]+.(jpe?g|gif|png|mov|swf|avi|mpe?g|mp3|wav|wmv)$ - [F]
Note: The file is four lines, and each line starts with Rewrite…
Categories: Apache
1 Comment »