Apache mod_rewrite

All examples need this code:

RewriteEngine On

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''
RewriteCond %{REQUEST_URI} !^/server-(status|info)/?$
Add a new environment variable

You can access this in PHP through the $_SERVER array.

RewriteCond %{REQUEST_URI} steve\.php$
RewriteRule . - [E=VARIABLE_NAME:variable_value,L]