httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Andersson" <rob...@profundis.nu>
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>/PYRWQMP.map
>
> ...will behave differently than:
>
> http://localhost/cgi-bin/mapserv.exe?map=<snip>/config.map

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=/blah1.map [NS,L]
RewriteRule ^/cgi-bin/mapserv-2$ /cgi-bin/mapserv.exe?map=/blah2.map [NS,L]
RewriteRule ^/cgi-bin/mapserv-3$ /cgi-bin/mapserv.exe?map=/blah3.map [NS,L]
# Or a slightly more flexible (and unsecure) approach
RewriteRule ^/cgi-bin/mapserv-(.+)$ /cgi-bin/mapserv.exe?map=path/$1.map
[NS,L]

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

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=/blah1.map&%{QUERY_STRING}. Note, howerver, that
this might be a sequrity issue, because the user might be able to replace
the map parameter.

Regards,
Robert Andersson


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message