Question: 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:

```
http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/apps/example/polt.map

```

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

```
http://localhost/mywms

```

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
</Directory>

```

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

```
http://localhost/wmsmap?layer=Green&mode=map

```

I got

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

```

Where is my mistake?

**UPDATE**

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
</Directory>

```

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?

Answer: 
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"
</Location>

```
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
</Directory>

```