I got an Apache and MapServer bundle (MS4W). On MapServer I made a WMS service and connect it to clients (Leaflet, QGIS etc.) with an URL like this:


In MapServer documentation I found that Apache can convert this URL in something like this:


In httpd.conf I see that rewrite module is on

LoadModule rewrite_module modules/mod_rewrite.so

Also I had added this block

<Directory C:\ms4w\apps\htdocs>
  AllowOverride All

After I created .htaccess file in C:\ms4w\apps\htdocs

RewriteEngine on
RewriteRule wmsmap?(.*) /cgi-bin/mapserv?map=C:/ms4w/apps/example/polt.map&$1

After I restarted Apache. But when I try to open with URL


I got

The requested URL /wmsmap was not found on this server.

Where is my mistake?


I had removed Directory block what I added in httpd.conf file. And edit default block so I got:

<Directory "/ms4w/Apache/htdocs">
  Options Indexes FollowSymLinks
  AllowOverride All
  #Require all granted

After I put .htaccess file in /ms4w/Apache/htdocs. And now I got another error on same URL:

msSaveImage(): Unable to access file. Failed to create output file (/tmp/WMS15201604824704.png).

What permission do I need?

  • @JGH oh, sorry. Just a typo in copypaste.
    – Kliver Max
    Mar 4 '18 at 14:37
  • Mode=map& doesn't give you a WMS response
    – nmtoken
    Mar 12 '18 at 8:39
  • Windows needs modify access to what ever folder location you have mapped as /tmp.
    – nmtoken
    Nov 12 '18 at 8:43

This works for me, but I don't know how to use .htaccess file too.

Alias /wmsmap "d:/ms4w/Apache/cgi-bin/mapserv.exe"
<Location /wmsmap >
   SetHandler cgi-script
   Options ExecCGI
   SetEnv MS_MAPFILE "d:/ms4w/apps/cgi-viewer/map/wmsdemo1.map"
  • .htaccess settings don't affect the mapping
    – nmtoken
    Nov 12 '18 at 8:44

Just create an alias on Apache. Like so:

<VirtualHost *> 
ServerName example.com
DocumentRoot /var/www/html/mjp

Alias /ncn "/var/www/html/ncn"

<Directory "/var/www/html/ncn">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all

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.