Apache Mod_Rewrite 问号
Apache Mod_Rewrite Question Mark
我需要使用以下 URL 重定向传入请求:
http://mywebsite.com/abc/mapserv.exe?map=123
到
http://mywebsite.com/abc/mapserv.exe?map=C:\Mapserver\ms4w\Apache\htdocs\Mapfiles3.map
我已经设法做到了简单的 mod_rewrites 但是问号一直在扼杀这个问题。我无法根据我的案例调整常见的查询字符串示例,因此我需要帮助解决这个确切的案例。
好像你没有展示你的尝试,你可以测试一下:
RewriteEngine On
RewriteCond %{QUERY_STRING} map=([0-9]+)$
RewriteRule . %{REQUEST_URI}?map=C:\Mapserver\ms4w\Apache\htdocs\Mapfiles\%1.map [NE,L]
重写使用的标志:
NE:不逃脱,
L:最后一条指令 运行.
我仍然无法使用 .exe url,因为如果您在发送请求时没有正确传递参数,则无法访问它。然后重定向不会触发。所以我制作了一个虚拟 mapserver.php 文件,允许设置如下参数:
http://mywebsite.com/abc/mapserver.php?map=123
经过几个小时的尝试,我得到了以下 RewriteRule:
RewriteCond %{QUERY_STRING} ^map=(.*)$
RewriteRule ^mapserver.php?$ /cgi-bin/mapserv.exe?map=C://Mapserver//ms4w//Apache//htdocs//Mapfiles//%1.map
我需要使用以下 URL 重定向传入请求:
http://mywebsite.com/abc/mapserv.exe?map=123
到
http://mywebsite.com/abc/mapserv.exe?map=C:\Mapserver\ms4w\Apache\htdocs\Mapfiles3.map
我已经设法做到了简单的 mod_rewrites 但是问号一直在扼杀这个问题。我无法根据我的案例调整常见的查询字符串示例,因此我需要帮助解决这个确切的案例。
好像你没有展示你的尝试,你可以测试一下:
RewriteEngine On
RewriteCond %{QUERY_STRING} map=([0-9]+)$
RewriteRule . %{REQUEST_URI}?map=C:\Mapserver\ms4w\Apache\htdocs\Mapfiles\%1.map [NE,L]
重写使用的标志: NE:不逃脱, L:最后一条指令 运行.
我仍然无法使用 .exe url,因为如果您在发送请求时没有正确传递参数,则无法访问它。然后重定向不会触发。所以我制作了一个虚拟 mapserver.php 文件,允许设置如下参数:
http://mywebsite.com/abc/mapserver.php?map=123
经过几个小时的尝试,我得到了以下 RewriteRule:
RewriteCond %{QUERY_STRING} ^map=(.*)$
RewriteRule ^mapserver.php?$ /cgi-bin/mapserv.exe?map=C://Mapserver//ms4w//Apache//htdocs//Mapfiles//%1.map