[mapserver-users] Correct Mod Rewrite rule

Paul Lewis paul.lewis at igeotec.com
Mon Jun 13 02:28:02 PDT 2022


I Want to change this:


*https://<our 
server>/cgi-bin/mapserv?map=/usr/share/mapserv/mapfile.map&service=wms&version=1.3.0&request=GetCapabilities*

To this:

*https://<our server>/wms?service=WMS&version=1.3.0&request=GetCapabilities*

So I've enabled apache2 mod-rewrite and created a .htaccess file with 
the following rule as per Mapserver docs:

*RewriteEngine on**
**RewriteRule wms?(.*) 
/cgi-bin/mapserv?map=/usr/share/mapserv/mapfile.map&$1**
*
I've also adapted this rule to numerous variations to try and get it 
working but to no avail.
The first link returns xml as expected.
The second link returns this error:

*mapserv(): Web application error. Traditional BROWSE mode requires a 
TEMPLATE in the WEB section, but none was provided.*

I've an error log running for the rewrite with an example trace as follows:


*[Thu Jun 09 18:54:22.033848 2022] [rewrite:trace3] [pid 40275:tid 
140188000974592] mod_rewrite.c(483): [client <browser IP>:62351] 
<browser IP> - - [<our 
server>/sid#7f80151c0340][rid#7f80147130a0/initial] [perdir 
/var/www/html/] strip per-dir prefix: /var/www/html/wms -> wms**
**[Thu Jun 09 18:54:22.033855 2022] [rewrite:trace3] [pid 40275:tid 
140188000974592] mod_rewrite.c(483): [client <browser IP>:62351] 
<browser IP> - - [<our 
server>/sid#7f80151c0340][rid#7f80147130a0/initial] [perdir 
/var/www/html/] applying pattern 'wms?(.*)' to uri 'wms'**
**[Thu Jun 09 18:54:22.033864 2022] [rewrite:trace2] [pid 40275:tid 
140188000974592] mod_rewrite.c(483): [client <browser IP>:62351] 
<browser IP> - - [<our 
server>/sid#7f80151c0340][rid#7f80147130a0/initial] [perdir 
/var/www/html/] rewrite 'wms' -> 
'/cgi-bin/mapserv?map=/usr/share/mapserv/gni_wms.map&'**
**[Thu Jun 09 18:54:22.033870 2022] [rewrite:trace3] [pid 40275:tid 
140188000974592] mod_rewrite.c(483): [client <browser IP>:62351] 
<browser IP> - - [<our 
server>/sid#7f80151c0340][rid#7f80147130a0/initial] split 
uri=/cgi-bin/mapserv?map=/usr/share/mapserv/gni_wms.map& -> 
uri=/cgi-bin/mapserv, args=map=/usr/share/mapserv/gni_wms.map**
**[Thu Jun 09 18:54:22.033877 2022] [rewrite:trace2] [pid 40275:tid 
140188000974592] mod_rewrite.c(483): [client <browser IP>:62351] 
<browser IP> - - [<our 
server>/sid#7f80151c0340][rid#7f80147130a0/initial] [perdir 
/var/www/html/] trying to replace context docroot /var/www/html with 
context prefix**
**[Thu Jun 09 18:54:22.033883 2022] [rewrite:trace1] [pid 40275:tid 
140188000974592] mod_rewrite.c(483): [client <browser IP>:62351] 
<browser IP> - - [<our 
server>/sid#7f80151c0340][rid#7f80147130a0/initial] [perdir 
/var/www/html/] internal redirect with /cgi-bin/mapserv [INTERNAL 
REDIRECT]**
*


Am I correct in thinking that the redirect is not handling the GET params?

Which means my rule is wrong and is hence passing the wrong request 
string to mapserver thus causing the error?


Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20220613/980f589b/attachment.htm>


More information about the MapServer-users mailing list