skip to Main Content

I need to redirect an incoming request with the following URL:

http://mywebsite.com/abc/mapserv.exe?map=123

to

http://mywebsite.com/abc/mapserv.exe?map=C:Mapserverms4wApachehtdocsMapfiles123.map

I already managed to do simple mod_rewrites but the question mark is killing this one all the time. I am not able to adapt common Query String examples to my case so I need help with this exact case.

2

Answers


  1. Chosen as BEST ANSWER

    I was still having trouble with the .exe url since it is not accessible if you dont deliver the parameters right when you send the request. And then the redirect wont fire. So I made a dummy mapserver.php file which allows setting a parameter like so:

    http://mywebsite.com/abc/mapserver.php?map=123

    After hours of trying I ended up with the following RewriteRule:

    RewriteCond %{QUERY_STRING} ^map=(.*)$
    RewriteRule ^mapserver.php?$ /cgi-bin/mapserv.exe?map=C://Mapserver//ms4w//Apache//htdocs//Mapfiles//%1.map
    

  2. As though you did not show your try, you could test this:

    RewriteEngine On
    RewriteCond %{QUERY_STRING} map=([0-9]+)$
    RewriteRule . %{REQUEST_URI}?map=C:\Mapserver\ms4w\Apache\htdocs\Mapfiles\%1.map [NE,L]
    

    Rewrite flags used:
    NE: Not Escape,
    L: Last instruction to run.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search