What is .htaccess?
.htaccess is a configuration file for use on web servers running the Apache Web Server software. When a .htaccess file is placed in a directory which is in turn 'loaded via the Apache Web Server', then the .htaccess file is detected and executed by the Apache Web Server software. These .htaccess files can be used to alter the configuration of the Apache Web Server software to enable/disable additional functionality and features that the Apache Web Server software has to offer. These facilities include basic redirect functionality, for instance if a 404 file not found error occurs, or for more advanced functions such as content password protection or image hot link prevention.
Table of Contents
- What is .htaccess?
- How to use .htaccess
- Error documents
- Password protection
- Deny visitors by IP address
- Deny visitors by referrer
- Hot link prevention techniques
- Blocking offline browsers and 'bad bots'
- DirectoryIndex uses
- Adding MIME types
- Enable SSI with .htaccess
- Enable CGI outside of the cgi-bin
- Disable directory listings
- Setting server timezone
- Changing server signature
- Preventing access to your PHP includes files
- Prevent access to php.ini
- Forcing scripts to display as source code
- Ensuring media files are downloaded instead of played
- Setting up Associations for Encoded Files
- Preventing requests with invalid characters
- Useful Resources
"This is the best article about .htaccess I've yet found! I love it! It is like php.net for .htaccess. It was a tutorial/guide that was really missed in my collection of web-creation sites, and now I would go as far as call it complete.
Thank you for this great site!"
"its damn good. great tweaks. keep on adding more.."
"One of the best guide you can get on htaccess."
"I agree, Fantastic article on .htaccess"
"It's a very useful .htaccess guide! Thanks!"
"Just the site I've been looking for. Well done"
"Perfect resource! Well done."
"Excellent site with fantastic references... Well done indeed!"
"Completely accurate as well as informative information for people engaged in web development & networking...thanks a lot... Please publish more & more such incredible tweaks. Regards, Rahul Baharwal"
"Great stuff. Easy enough for newbies to follow but detailed enough for more advanced users. Much respect."
"I hate to use the word great. It's over used and boring. I'd say that this is excellent! Yep, excellent... I really learned a great deal about .htaccess that I hadn't had the fortune to have been exposed to before now. Security is a passion of mine. I hate getting ripped off. So, the tweaks to the .htaccess file will help me a great deal. Thanks for the most excellent and useful information! Randy Wells"