howto use htaccess apache
I just came across a great article that give at least a hundred htaccess examples in different situations. It can be found here.
Table of Contents
- General
- Essentials
- Performance
- disable
AllowOverride
- pass the character set
- preserve bandwidth
- disable the server signature
- set the server timezone
- set admin email address
- enable file caching
- set default language & character set
- declare specific/additional MIME types
- send headers without meta tags
- limit request methods to GET/PUT
- process files according to request method
- execute various file types via CGI script
- disable
- Security
- prevent access to htaccess
- prevent access to any file
- prevent acess to multiple file types
- prevent unauthorized directory browsing
- change the default index page
- disguise script extensions
- limit access to the LAN
- secure directories by IP or domain
- deny/allow domain access for IP range
- deny/allow multiple IP addresses on one line
- miscellaneous rules for blocking/allowing
- stop hotlinking, serve alternate content
- block robots, rippers, and offline browsers
- more stupid blocking tricks
- even more scum-blocking tricks
- password-protect directories
- password-protect files, directories, and more
- require SSL (secure sockets layer)
- automatically CHMOD various file types
- disguise all file extensions
- limit file upload size
- disable script execution
- Usability
- minimize CSS image flicker in IE6
- deploy custom error pages
- provide a universal error document
- employ basic URL spelling check
- force media downloads
- display file source code
- redirect visitors during site development
- provide password-prompt during site development
- prevent access during specified time periods
- Redirects
- important note about redirecting via
mod_rewrite
- redirect from www-domain to non-www-domain
- redirect from an old domain to a new domain
- redirect string variations to a specific address
- other fantastic redirect tricks
- send visitors to a subdomain
- more fun with RewriteCond & RewriteRule
- more fun with Redirect 301 & RedirectMatch 301
- important note about redirecting via
- WordPress
- Random
- References
Here are some of the references this article uses:
- 1 Wikipedia htaccess Resource
- 2 Apache Cookbook
- 3 Ultimate htaccess Article
- More on regular expressions
- Apache htaccess Reference
- Apache htaccess Tutorial
- Apache mod_rewrite
- htaccess Forum
- Behind the Scenes with htaccess
- Automatic htaccess file generator