Newbie .htaccess Tutorial
By
Billy
"What is that .htaccess thing?"
.htaccess is a ascii text file used to over-ride your Apache web-servers configuration and has many weird, wonky and wonderful uses! This tutorial focues on preventing thiefs from hotlinking your images and those "chat-room" folks who like to pretend they are your favourite model by posting the url to one of your images.
note: when creating your .htaccess file, it must be saved with no file type extension! If your text editor won't allow you to save a file without an extension, most FTP clients will let you remove it after you've uploaded it to your server.
"Where do you put that thing?"
Wherever it's needed! You can have a single .htaccess file protecting your entire domain, protecting a single directory(eg. images/), or, have many .htaccess files. each protecting a different directory. Sometimes simple is better, using a single .htaccess file to protect your image directory will help you avoid problems managing/changing multiple files across your domains. I normally use a single .htaccess file in my document root directory and sometimes put niche-specific .htaccess files in some sub-directories.
"Show me that thing!"
AuthUserFile /dev/null AuthGroupFile /dev/null RewriteEngine On RewriteCond %{HTTP_REFERER} !^http://www.newbie.com/.*$ [NC] ReWriteRule .*\.jpg$ http://www.hotlinker-hell.com [R,L]
"What do those things do?"
AuthUserFile /dev/null
AuthGroupFile /dev/null
No passwords are required for individual users or groups of users
RewriteEngine On
Have to turn it on, before it will work....... :)
RewriteCond %{HTTP_REFERER} !^http://www.newbie.com/.*$ [NC]
If the referring url "HTTP_REFERER" does not start with your domain "http://www.newbie.com/", then this conditional statement is true
and the next "RewriteRule" encountered will be executed.



