Set Environment Variables According To URL

Ask your mod_rewrite and Redirection questions here, and get answers!

Set Environment Variables According To URL

Postby produke » 30 Oct 2006 20:38

Description:

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.
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".
Code: Select all
RewriteEngine on
RewriteRule   ^(.*)/S=([^/]+)/(.*)$1/$3 [E=STATUS:$2]
User avatar
produke
 
Posts: 242
Joined: 25 Sep 2006 04:48

Return to Redirect or Rewrite Questions



Who is online

Users browsing this forum: ALATaiplewType, NQBrunsecessy, ShakhtarrDon, VocrepeAcceby, Zitioutbava