A small yet handy cheat sheet for mod_rewrite. The most used items to build a mod_rewrite pattern.
Despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still voodoo.
RewriteRule Pattern Substituion [Flag(s)]
RewriteRule &/oldfile\.html$ /newfile.html
. Every char < > = Compare \ Escape a char .+ One more, more chars .* No chars or multiple chars ^ Start $ End (…) Group a|b .A or B (a|b) .A or B group a{5} Exact 5 times a a{1,5} Between 1 and 5 times a [a-z]* Match chars -d Directory -f File -l Symbolic link
[NC] No case sensitive [OR] Allows multiple lines [R=#] Redirect where # is number: 404. [L] Terminate routine
%{HTTP_ACCEPT} Media types accepted by the client, ?text/plain? %{HTTP_COOKIE} Cookies set for the client. %{HTTP_HOST} Domain name of the virtual host queried. %{HTTP_REFERER} Page with a link to this page (can be omitted). %{HTTP_USER_AGENT} Client, such as ?Mozilla/4.0? %{QUERY_STRING} Query string transferred by a GET form. %{REMOTE_ADDR} Client IP address. %{REMOTE_HOST} Domain name of client. %{REMOTE_USER} User name of the client. %{REQUEST_URI} The URI requested by the client. %{REQUEST_FILENAME} The corresponding file on the local file system. %{SERVER_ADDR} Server IP
Jan 19
This entry was posted on Friday, January 19th, 2007 at 9:25 pmand is filed under everyday. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
5 Comments Apache Mod_Rewrite Cheat Sheet
Top Gossips » Blog Archive » 70+ Practical Cheat Sheets For Web Designers And Developers
April 16th, 2009 at 7:31 pm
1[...] Web Based Mod_Rewrite Tips [...]
10+ Mod_Rewrite Rules You Should Know
August 18th, 2009 at 1:52 am
2[...] Apache Mod_Rewrite Cheat Sheet – This cheat sheet offers information on the most-used items for building a mod_rewrite pattern. [...]
10+ Mod_Rewrite Rules You Should Know | SeanBurdick
August 19th, 2009 at 3:10 am
3[...] Apache Mod_Rewrite Cheat Sheet – This cheat sheet offers information on the most-used items for building a mod_rewrite pattern. [...]
Expectually Useful Apache Rewrite Techniques Explained | tripwire magazine
August 25th, 2009 at 5:08 pm
4[...] Apache Mod_Rewrite Cheat Sheet – This cheat sheet offers information on the most-used items for building a mod_rewrite pattern. [...]
Expectually Useful Apache Rewrite Techniques Explained « Mahesh Prasad ( Web Development ) [LAMP/AJAX/SEO/SQL/XML]
August 26th, 2009 at 5:47 am
5[...] This article will show you some really useful Apache Rewrite Techniques and easy to digest introduction to Apache basics. You may want to get yourself a cheat sheet before going on: Apache Mod_Rewrite Cheat Sheet [...]
RSS feed for comments on this post · TrackBack URI
Leave a Reply Apache Mod_Rewrite Cheat Sheet