我已经安装了isapi_rewrite的完整版本,并设置了一个代理指令,以便我的工作站在“ngis”文件夹(在任何端口上)的所有流量都转到另一台服务器。这是出于测试目的,在将isapi_redirect推广到我们的prod服务器之前检查适用性。
我的规则如下:
RewriteRule ^ngis/(.+)$ http://10.2.25.157:8080/ngis/$1 [NC, P]
当我输入URL时,这非常有效:
http://10.1.111.20:8080/ngis/QueryEngine.ptl/DocTree(%60/2007/MELBOURNE/R01%60,%601%60).xml
但是,如果我输入带有查询字符串的UIRL,例如:
http://10.1.111.20:8080/ngis/QueryEngine.ptl/DocTree(%60/2007/MELBOURNE/R01%60,%601%60).xml?VIEW=RAW
我收到“无法找到页面”错误。
查看日志,步骤看起来是一样的。以下是上述两个请求的日志条目:
[10.1.111.20/sid#1][rid#11050940/initial] (2) init rewrite engine with requested uri /ngis/QueryEngine.ptl/DocTree(`/2007/MELBOURNE/R01`,`1`).xml
[10.1.111.20/sid#1][rid#11050940/initial] (1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
[10.1.111.20/sid#1][rid#11050940/initial] (1) Htaccess process request c:\inetpub\wwwroot\.htaccess
[10.1.111.20/sid#1][rid#11050940/initial] (3) applying pattern '^ngis/(.+)$' to uri 'ngis/QueryEngine.ptl/DocTree(`/2007/MELBOURNE/R01`,`1`).xml'
[10.1.111.20/sid#1][rid#11050940/initial] (2) forcing proxy-throughput with http://10.2.25.157:8080/ngis/QueryEngine.ptl/DocTree(`/2007/MELBOURNE/R01`,`1`).xml
[10.1.111.20/sid#1][rid#11050940/initial] (1) go-ahead with proxy request http://10.2.25.157:8080/ngis/QueryEngine.ptl/DocTree(`/2007/MELBOURNE/R01`,`1`).xml [OK]
[10.1.111.20/sid#1][rid#11050940/initial] (1) Rewrite URL to >> http://10.2.25.157:8080/ngis/QueryEngine.ptl/DocTree(`/2007/MELBOURNE/R01`,`1`).xmlx.rwhlp?p=2
[10.1.111.20/sid#1][rid#11050940/initial] (2) rewrite 'ngis/QueryEngine.ptl/DocTree(`/2007/MELBOURNE/R01`,`1`).xml' -> 'http://10.2.25.157:8080/ngis/QueryEngine.ptl/DocTree(`/2007/MELBOURNE/R01`,`1`).xmlx.rwhlp?p=2'
[10.1.111.20/sid#1][rid#11050940/initial] (2) internal redirect with http://10.2.25.157:8080/ngis/QueryEngine.ptl/DocTree(`/2007/MELBOURNE/R01`,`1`).xmlx.rwhlp?p=2 [INTERNAL REDIRECT]
[10.1.111.20/sid#1][rid#11050940/initial] (2) init rewrite engine with requested uri /ngis/QueryEngine.ptl/DocTree(`/2007/MELBOURNE/R01`,`1`).xml?VIEW=RAW
[10.1.111.20/sid#1][rid#11050940/initial] (1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
[10.1.111.20/sid#1][rid#11050940/initial] (1) Htaccess process request c:\inetpub\wwwroot\.htaccess
[10.1.111.20/sid#1][rid#11050940/initial] (3) applying pattern '^ngis/(.+)$' to uri 'ngis/QueryEngine.ptl/DocTree(`/2007/MELBOURNE/R01`,`1`).xml'
[10.1.111.20/sid#1][rid#11050940/initial] (2) forcing proxy-throughput with http://10.2.25.157:8080/ngis/QueryEngine.ptl/DocTree(`/2007/MELBOURNE/R01`,`1`).xml?VIEW=RAW
[10.1.111.20/sid#1][rid#11050940/initial] (1) go-ahead with proxy request http://10.2.25.157:8080/ngis/QueryEngine.ptl/DocTree(`/2007/MELBOURNE/R01`,`1`).xml?VIEW=RAW [OK]
[10.1.111.20/sid#1][rid#11050940/initial] (1) Rewrite URL to >> http://10.2.25.157:8080/ngis/QueryEngine.ptl/DocTree(`/2007/MELBOURNE/R01`,`1`).xml?VIEW=RAWx.rwhlp?p=2
[10.1.111.20/sid#1][rid#11050940/initial] (2) rewrite 'ngis/QueryEngine.ptl/DocTree(`/2007/MELBOURNE/R01`,`1`).xml' -> 'http://10.2.25.157:8080/ngis/QueryEngine.ptl/DocTree(`/2007/MELBOURNE/R01`,`1`).xml?VIEW=RAWx.rwhlp?p=2'
[10.1.111.20/sid#1][rid#11050940/initial] (2) internal redirect with http://10.2.25.157:8080/ngis/QueryEngine.ptl/DocTree(`/2007/MELBOURNE/R01`,`1`).xml?VIEW=RAWx.rwhlp?p=2 [INTERNAL REDIRECT]
正如你所看到的,就isapi_rewrite而言,它已经发挥了作用。但是,我可以确认目标服务器没有收到请求(因为我们正在调试它以尝试诊断问题!)
这个问题似乎被一个'?'的存在所警告和一些查询字符串参数。
我已经尝试过RewriteRule和RewriteProxy并得到同样的问题。
有什么想法吗? 欢呼声。
答案 0 :(得分:0)
在apache中,我们使用[QSA]标志添加原始查询字符串,不确定isapi_rewrite。这个虚幻的x.rwhlp?p=2
追加来自哪里?
答案 1 :(得分:0)
我已经尝试了[QSA]标记,但是页面似乎仍然没有向远程服务器发出请求而抛出404。
x.rwhlp?p = 2附加了组件(据我所知),isapi_rewrite 3的安装为.rwhlp扩展创建了一个处理程序 - 这似乎是它的工作方式。但是,对目标服务器的请求不包括URL的这个附加部分。
答案 2 :(得分:0)
你必须像这样打破query_string:
RewriteCond %{QUERY_STRING} ^p=2$ [NC]
RewriteRule ^x\.rwhlp$ NewLocation [NC,R=301,P]
任何时候你点击"?",你必须打破"?"之后的任何事情。到query_string条件。必须以这种方式分解URL以处理字符串和页面调用。