httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Andersson" <>
Subject Re: [users@httpd] Setting environment variables based on query string specifics
Date Tue, 18 May 2004 12:04:53 GMT
Kralidis,Tom [Burlington] wrote:
> I have a CGI binary running in Apache.  The executable runs differently
> based on configuration files, i.e.
> http://localhost/cgi-bin/mapserv.exe?map=<snip>/
> ...will behave differently than:
> http://localhost/cgi-bin/mapserv.exe?map=<snip>/

A somewhat weird situation, but I guess mod_rewrite comes to the rescue. If
different URIs should cause the same application to be run with different
configs, you could do like this:

RewriteEngine On
# Forbid direct access
RewriteRule ^/cgi-bin/mapserv(\.exe)?$ - [F]
# Then map each configuration
RewriteRule ^/cgi-bin/mapserv-1$ /cgi-bin/mapserv.exe?map=/ [NS,L]
RewriteRule ^/cgi-bin/mapserv-2$ /cgi-bin/mapserv.exe?map=/ [NS,L]
RewriteRule ^/cgi-bin/mapserv-3$ /cgi-bin/mapserv.exe?map=/ [NS,L]
# Or a slightly more flexible (and unsecure) approach
RewriteRule ^/cgi-bin/mapserv-(.+)$ /cgi-bin/mapserv.exe?map=path/$

Not tested, and will probably require some more tweaks to work as you want

If you want to pass through the rest of the query string, I think you should
change right-hand substitution to something like:
/cgi-bin/mapserv.exe?map=/{QUERY_STRING}. Note, howerver, that
this might be a sequrity issue, because the user might be able to replace
the map parameter.

Robert Andersson

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message