Differences

This shows you the differences between two versions of the page.

Link to this comparison view

apache_mod_rewrite [2014/05/09 12:16] (current)
Line 1: Line 1:
 +====== Apache mod_rewrite ======
  
 +  * [[Apache]]
 +
 +  * [[http://​httpd.apache.org/​docs/​2.0/​mod/​mod_rewrite.html|mod_rewrite]]
 +  * [[http://​httpd.apache.org/​docs/​2.2/​rewrite/​intro.html|mod_rewrite intro]]
 +  * [[http://​www.askapache.com/​htaccess/​mod_rewrite-variables-cheatsheet.html|mod_rewrite Variables Cheatsheet]]
 +  * [[http://​www.cheatography.com/​davechild/​cheat-sheets/​mod-rewrite/​|mod_rewrite Cheat Sheet]]
 +
 +All examples need this code:
 +
 +<​code>​
 +RewriteEngine On
 +</​code>​
 +
 +Rewrite conditions are cumulative, and will redirect when a ''​RewriteRule''​ is given.
 +
 +Rewrite conditions also execute in listed order, so if the first one matches it will redirect, and the second one won't be read.
 +
 +You can use perl regular expressions.
 +
 +=== Examples ===
 +
 +== Match URLs that are not ''​server-status''​ or ''​server-info''​ ==
 +
 +<​code>​
 +RewriteCond %{REQUEST_URI} !^/​server-(status|info)/?​$
 +</​code>​
 +
 +== Add a new environment variable ==
 +
 +You can access this in PHP through the $_SERVER array.
 +
 +<​code>​
 +RewriteCond %{REQUEST_URI} steve\.php$
 +RewriteRule . - [E=VARIABLE_NAME:​variable_value,​L]
 +</​code>​