[mapserver-users] Rewrite rule problem

Eichner, Andreas - SID Andreas.Eichner at sid.sachsen.de
Wed Nov 1 00:32:07 PDT 2017


Hi Goran,

the RewriteRule should match the Location for SetEnvIfExpr:

  <Location "/cgi-bin/GDZ/wms">
    SetEnvIfExpr "%{QUERY_STRING} =~/^(.*&)?map=([[:alnum:]]+.map)(&.*)?$/" MS_MAPFILE=C:/ms4w/apps/Demo/$2
  </Location>

  RewriteEngine On
  RewriteRule /cgi-bin/GDZ/wms /cgi-bin/GDZ/wms?MAP=MS_MAPFILE [PT,QSA]

And then the URL

  http://localhost:81/cgi-bin/GDZ/wms?map=N1.map&REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.3.0

should set the MS_MAPFILE environment variable to "C:/ms4w/apps/Demo/N1.map" and rewrite the URL to 
  http://localhost:81/cgi-bin/GDZ/wms?MAP=MS_MAPFILE&map=N1.map&REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.3.0
This should work as MapServer scans the query parameters from left to right. It first finds MAP=MS_MAPFILE 
and checks if there's an environment variable set assuming that it points to a valid map file. 
The SetEnvIfExpr has set this variable for the URL "/cgi-bin/GDZ/wms" if a "MAP" parameter was provided.

HTH

> -----Ursprüngliche Nachricht-----
> Von: mapserver-users [mailto:mapserver-users-bounces at lists.osgeo.org] Im
> Auftrag von gorank
> Gesendet: Montag, 30. Oktober 2017 16:24
> An: mapserver-users at lists.osgeo.org
> Betreff: Re: [mapserver-users] Rewrite rule problem
> 
> Hi Andreas,
> 
> As you sugested I have added in* httpd.conf* file following
> 
> 
> and when I put URL
> 
> I receive the following message:
> msLoadMap(): Unable to access file. (N1.map)
> 
> As addition in the C:/ms4w/httpd.d folder I have file httpd_Demo.conf
> file
> with following content
> 
> Alias /Demo/ "/ms4w/apps/Demo/"
> <Directory "/ms4w/apps/Demo/">
>   AllowOverride None
>   Options Indexes FollowSymLinks Multiviews
>   Order allow,deny
>   Allow from all
> </Directory>
> 
> What I'm doing wrong.
> 
> Best regards,
> Goran
> 
> 
> 
> --
> Sent from: http://osgeo-org.1560.x6.nabble.com/Mapserver-User-
> f4226646.html
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/mapserver-users


More information about the MapServer-users mailing list