.htaccess: General
Deny From All
The deny from all .htaccess directive will prevent remote browser access to any files in the directory. Typically used to protect "/include" folders.
Disable PHP Magic Quotes
As you may know magic-quotes will be totally gone for PHP 6. If you haven't already started coding your PHP sites without magic quotes, now is the time to start. This snippet shows you how to disable magic quotes using .htaccess
.htaccess: mod_rewrite
301 Permanent Redirect
If the URL of a page is changed, a 301 permanent redirect should be created to point visitors to the new location and most importantly: help preserve existing search engine ranking.
Using .htaccess and mod_rewrite, 301 redirects can be easily created:
Spaces in URL
I recently had to create an .htaccess mod_rewrite rule to *preserve* an old URL that had spaces. After looking around, I found a simple solution that worked for the page in question: Just enclose the URL in quotes!
Remove WWW from URL
This mod_rewrite condition allows you to remove the "www" from a url and redirect the user to the non-www version.
Add WWW to URL
Use this mod_rewrite snippet to automatically add the www subdomain to the URL.



