PDA

View Full Version : apache htaccess cheatsheet



apachedude
30 Mar 2007, 07:47 PM
from: Apache htaccess google group (http://groups.google.com/group/apachehtaccess/web/htaccess-cheatsheet)

For Webmasters (http://www.askapache.com/2007/htaccess/htaccess-for-webmasters.html#for-apache-webmasters)
Custom HTTP Headers (http://www.askapache.com/2007/htaccess/using-http-headers-with-htaccess.html#http-headers-in-htaccess)
PHP htaccess tips (http://www.askapache.com/2007/htaccess/php-htaccess-tips-and-tricks.html#php-htaccess)
SEO Search Engine Friendly Redirects without mod_rewrite (http://www.askapache.com/2007/htaccess/seo-search-engine-friendly-redirects-without-mod_rewrite.html#seo-301-redirect)
mod_rewrite tips and tricks (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#mod_rewrite-tips-tricks)
Speed up your site with Caching and cache-control (http://www.askapache.com/2007/htaccess/speed-up-your-site-with-caching-and-cache-control.html#caching-with-htaccess)
Apache Authentication in htaccess (http://www.askapache.com/2007/htaccess/apache-authentication-in-htaccess.html#apache-authentication-in-htaccess)
Security with Apache htaccess (http://www.askapache.com/2007/htaccess/security-with-apache-htaccess.html#apache-htaccess-security)
SSL example usage in htaccess (http://www.askapache.com/2007/htaccess/ssl-example-usage-in-htaccess.html#ssl-in-htaccess-examples)
Apache Variable fun (mod_env) (http://www.askapache.com/2007/htaccess/apache-variable-fun-in-htaccess.html#apache-variable-mod-env)

When site is Under Construction (http://www.askapache.com/2007/htaccess/htaccess-for-webmasters.html#under-construction-code)
Redirect everyone to different site except 1 IP (http://www.askapache.com/2007/htaccess/htaccess-for-webmasters.html#redirect-except-1-ip)
Redirect everyone to different site except 1 IP (http://www.askapache.com/2007/htaccess/htaccess-for-webmasters.html#redirect-except-1-ip-mod-rewrite)
Redirect Everyone but you to alternate page on your server. (http://www.askapache.com/2007/htaccess/htaccess-for-webmasters.html#redirect-all-to-alternate-file)
Set the Timezone of the server (http://www.askapache.com/2007/htaccess/htaccess-for-webmasters.html#set-server-timezone)
Set the Server Administrator Email (http://www.askapache.com/2007/htaccess/htaccess-for-webmasters.html#server-administrator-email)
Turn off the ServerSignature (http://www.askapache.com/2007/htaccess/htaccess-for-webmasters.html#turn-off-serversignature)
Force Files to download, do not display in browser (http://www.askapache.com/2007/htaccess/htaccess-for-webmasters.html#force-download-octet-stream)
Process All .gif files with a cgi script (http://www.askapache.com/2007/htaccess/htaccess-for-webmasters.html#process-file-through-cgi)
Process Requests with certain Request Methods (http://www.askapache.com/2007/htaccess/htaccess-for-webmasters.html#process-request-methods-with-script)
Make any file be a certain filetype (http://www.askapache.com/2007/htaccess/htaccess-for-webmasters.html#force-filetype-with-forcetype)
Use IfModule directive for robust code (http://www.askapache.com/2007/htaccess/htaccess-for-webmasters.html#ifmodule-in-apache)

Prevent Caching 100% (http://www.askapache.com/2007/htaccess/using-http-headers-with-htaccess.html#prevent-caching-with-htaccess)
Remove IE imagetoolbar without meta tag (http://www.askapache.com/2007/htaccess/using-http-headers-with-htaccess.html#remove-ie-imagetoolbar)
Add Privacy (P3P) Header to your site (http://www.askapache.com/2007/htaccess/using-http-headers-with-htaccess.html#privacy-p3p-header-in-apache)
Add a en-us language header and urf-8 without meta tags! (http://www.askapache.com/2007/htaccess/using-http-headers-with-htaccess.html#language-and-content-header-in-htaccess)

Using AddType (http://www.askapache.com/2007/htaccess/using-http-headers-with-htaccess.html#sub-just-using-addtype)
Using the Files Directive (http://www.askapache.com/2007/htaccess/using-http-headers-with-htaccess.html#sub-using-the-files-directive)
Using the FilesMatch Directive (http://www.askapache.com/2007/htaccess/using-http-headers-with-htaccess.html#sub-using-the-filesmatch-directive)


When php run as CGI (http://www.askapache.com/2007/htaccess/php-htaccess-tips-and-tricks.html#php-run-as-cgi)
Use a custom php.ini with mod_php or php as a cgi (http://www.askapache.com/2007/htaccess/php-htaccess-tips-and-tricks.html#htaccess-php-ini)

When php run as Apache Module (mod_php) (http://www.askapache.com/2007/htaccess/php-htaccess-tips-and-tricks.html#sub-mod_php)
When cgi php is run with wrapper (FastCGI) (http://www.askapache.com/2007/htaccess/php-htaccess-tips-and-tricks.html#php-and-fastcgi-in-htaccess)


For single moved file (http://www.askapache.com/2007/htaccess/seo-search-engine-friendly-redirects-without-mod_rewrite.html#seo-301-redirect-single-file)
Redirect Home to new Domain (http://www.askapache.com/2007/htaccess/seo-search-engine-friendly-redirects-without-mod_rewrite.html#seo-301-redirect-new-domain)
For multiple files like a blog/this.php?gh (http://www.askapache.com/2007/htaccess/seo-search-engine-friendly-redirects-without-mod_rewrite.html#seo-301-redirect-multiple-files)
Redirect Entire site to single file (http://www.askapache.com/2007/htaccess/seo-search-engine-friendly-redirects-without-mod_rewrite.html#seo-302-redirectmatch-site-to-single-file)

Mostly .htaccess rewrite examples should begin with: (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#default-mod-rewrite-hint)
Check for a key in QUERY_STRING (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#check-for-key-in-query-string)
Removes the QUERY_STRING from the URL (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#delete-query-string)
Fix for infinite loops (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#fix-infinite-loop-redirects)
Require the www (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#require-the-www-in-htaccess)
Require no www (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#require-no-www-in-htaccess)
Redirect .php files to .html files (SEO friendly) (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#external-redirect-php-files-to-html)
Redirect .html files to actual .php files (SEO friendly) (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#internal-redirect-php-files-to-html)
block access to files during certain hours of the day (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#time-based-access)
Rewrite underscores to hyphens for SEO URL (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#convert-underscore-hyphen)
Require the www without hardcoding (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#require-www-no-hardcoding)
Require no subdomain (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#require-no-subdomain-1)
Require no subdomain (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#require-no-subdomain-2)
Redirecting Wordpress Feeds to Feedburner (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#redirect-wordpress-feed)
Only allow GET and PUT request methods (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#only-allow-get-and-put-requests)
Prevent Files image/file hotlinking and bandwidth stealing (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#prevent-hotlinking)
Stop browser prefetching (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#stop-browser-prefetching)
Make a prefetching hint for Firefox. (http://www.askapache.com/2007/htaccess/mod_rewrite-tips-and-tricks.html#firefox-prefetching-hint)
htaccess time cheatsheet (http://www.askapache.com/2007/htaccess/speed-up-your-site-with-caching-and-cache-control.html#htaccess-time-cheatsheet)
Caching with both mod_expires + mod_headers (http://www.askapache.com/2007/htaccess/speed-up-your-site-with-caching-and-cache-control.html#caching-with-both-modules)
Caching with mod_headers (http://www.askapache.com/2007/htaccess/speed-up-your-site-with-caching-and-cache-control.html#caching-with-mod_headers)
Caching with mod_expires (http://www.askapache.com/2007/htaccess/speed-up-your-site-with-caching-and-cache-control.html#caching-with-mod_expires)

Require password for 1 file only (http://www.askapache.com/2007/htaccess/apache-authentication-in-htaccess.html#require-password-for-single-file)
Protect multiple files: (http://www.askapache.com/2007/htaccess/apache-authentication-in-htaccess.html#protecting-multiple-files)
Using the Apache Allow Directive in htaccess (http://www.askapache.com/2007/htaccess/apache-authentication-in-htaccess.html#using-allow-directive-in-apache)

Hope this helps!