1

I consolidate all my .map files and data under a root folder. (eg. c:\data)

Under the url when accessing .map file via Mapserver, instead of defining an absolute full path:

http://localhost/cgi-bin/mapserv.exe?map=c:/data/sample.map&layer=sample&mode=map

I will like to specify a relative pathing to c:\data like this:

http://localhost/cgi-bin/mapserv.exe?map=sample.map&layer=sample&mode=map

Or have some way to replace c:\data with a keyword (eg. DATA_ROOT) like this:

http://localhost/cgi-bin/mapserv.exe?map=DATA_ROOT/sample.map&layer=sample&mode=map

Is one of the above possible? Also, I am using the pre-built binaries version of Mapserver.

  • There is no concept of a data root, for a mapserver installation, or for a mapserver service. You can use local references within any map file to include other map files – nmtoken Mar 12 at 6:31
3

I think it would not be a good idea to expose the internal directory structure in URLs, so both the .exe and the .map files are configured explicitly behind a virtual path:

<Location "/thismap">
  ScriptAlias "c:/ms4w/Apache/cgi-bin/mapserv.exe"
  SetEnv MS_MAPFILE "c:/data/config/this.map"
</Location>
<Location "/anothermap">
  ScriptAlias "c:/ms4w/Apache/cgi-bin/mapserv.exe"
  SetEnv MS_MAPFILE "c:/data/config/another.map"
</Location>

resulting in, e.g., http://localhost/thismap?layer=sample&mode=map.

And then it makes sense to use a macro for these:

<Macro MSMap $URL $config>
  <Location "$URL">
    ScriptAlias "c:/ms4w/Apache/cgi-bin/mapserv.exe"
    SetEnv MS_MAPFILE "c:/data/config/$config"
  </Location>
</Macro>

Use MSMap /thismap   this.map
...
  • Thank you, this solution will solve my problem! – ssaga Mar 13 at 1:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.