Set Environment Variables According To URL

Perhaps you want to keep status information between requests and use the URL to encode it. But you don't want to use a CGI wrapper for all pages just to strip out this information.

Environment Variable Solution

We use a rewrite rule to strip out the status information and remember it via an environment variable which can be later dereferenced from within XSSI or CGI. This way a URL /foo/S=java/bar/ gets translated to /foo/bar/ and the environment variable named STATUS is set to the value "java".

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)/S=([^/]+)/(.*)$1/$3 [E=STATUS:$2]
From: Set Environment Variables According to URL

Htaccess Htaccess mod_rewrite RewriteRule