FREE THOUGHT · FREE SOFTWARE · FREE WORLD

Home » Htaccess » Set Environment Variables According To URL

Set Environment Variables According To URL

Set Environment Variables According To URL » Set Environment Variables According To URL

Set Environment Variables According To URL

November 7th, 2006

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

Add Comment!

Leave a Reply

Your email address will not be published.


Google +

It's very simple - you read the protocol and write the code. -Bill Joy

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License, just credit with a link.
This site is not supported or endorsed by The Apache Software Foundation (ASF). All software and documentation produced by The ASF is licensed. "Apache" is a trademark of The ASF. NCSA HTTPd.
UNIX ® is a registered Trademark of The Open Group. POSIX ® is a registered Trademark of The IEEE.

Site Map | Contact Webmaster | Glossary | License and Disclaimer | Terms of Service |

↑ TOPMain