I am having a hard time trying to figure out how to hide the file path value of Query String MAP parameter available on a MapServer request as shown bellow: http://192.168.15.150/mapserver?MAP=/data/config/map/nasaww.map&%20service=wms&version=1.3.0&CRS=CRS:84&REQUEST=GetMap&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-170,-90,170,90&WIDTH=600&HEIGHT=600&LAYERS=BlueMarble-200407&STYLE=raster I am trying two solutions:
Based on MapServer Env Variables - However this solution hind the MAP variable or replace the MAP value for a variable. Not really what I am looking for.
Use the Apache mod_rewrite as shown here. I have configured my Virtualhost as shown bellow:
<Directory /data> Options Indexes FollowSymLinks AllowOverride AuthConfig Order allow,deny Allow from all RewriteEngine on RewriteCond %{REQUEST_URI} ^/mapserver/?$ RewriteCond %{QUERY_STRING} (^|&)MAP=([A-Z]).map(&|$) [NC] RewriteRule (.) http://192.168.15.150/wms?MAP=/data/config/map/%1 [R=301,NC,L,QSA]
Alias /mapserver /usr/lib/cgi-bin/mapserv <location /mapserver> setHandler cgi-script Options +ExecCGI -MultiViews +FollowSymLinks AddHandler fcgid-script .fcgi Require all granted SetEnv MY_PATH "/data/config/map/" SetEnv MY_MAPFILE "/data/config/map/nasaww.map"
The Apache rewrite solution still did not work. Would anyone point me to any miss-configuration or give me some highlights to achieve my goal.
This is fully documented (by me, small world) on the official MapServer site, which gives several options for you to hide the
map=parameter from the request: https://mapserver.org/ogc/wms_server.html#changing-the-online-resource-urlThat said, you might ask though 'which one do you recommend?', and here's my answer:
for Linux: I use a wrapper script, which I always copy/paste from https://mapserver.org/ogc/wms_server.html#wrapper-script-unix
for Windows: I use a modification of that same method, but using the Apache
SetEnvIfparameter in httpd.conf: https://mapserver.org/ogc/wms_server.html#apache-setenvifLet me know if that documentation needs any updates. Thanks! -jeff