ASP反向代理解析二级目录

创建:2020年4月17日  作者:清风明月

运行环境:Win2003 IIS6 + ISAPI_Rewrite 1.3

Windows Server 2003 服务器上先安装好 ISAPI_Rewrite 1.3

网站根目录下新建 httpd.ini 和 proxy.asp 两个文件

httpd.ini 是 ISAPI_Rewrite 的URL重写配置文件,代码如下:


[ISAPI_Rewrite]

#throughput all content of /mulu folder to another server
RewriteRule  /mulu(.*)  /proxy.asp\?http\://web.c12345.com/html5test$1

mulu 是二级目录名称,http\://web.c12345.com/html5test 是要反向代理解析的地址

proxy.asp 代码


<%@ Language=JScript EnableSessionState=False%>
<%

//we are using MSXML3.0 to travel via HTTP

var httpReq;
if(Request.QueryString.Count)
{
    httpReq=Server.CreateObject("Msxml2.ServerXMLHTTP");
    httpReq.setTimeouts(5000,5000,15000,15000);
    httpReq.open("GET",""+Request.QueryString, false);
    httpReq.send();
    Response.Status=httpReq.status;
    Response.ContentType=httpReq.getResponseHeader("Content-Type");
    Response.BinaryWrite(httpReq.responseBody);
}
%>