我作了一个url map的测试dll,根据MS提供的代码稍微作了修改,url跳转是没有问题了,但是地址栏上的url也换了。怎么让它网页跳转但是url还是我输入的url?
//source code:
DWORD CURL_reWriteFilter::OnUrlMap(CHttpFilterContext* pCtxt,
PHTTP_FILTER_URL_MAP pMapInfo)
{CHAR szRedirect [256];
bool bflag = false;if (strstr (pMapInfo->pszURL, "Index/"))
{
//CHAR szRedirect [256];
// replace www.microsoft.com with desired server
if(strstr(pMapInfo->pszURL,"2.html"))
{
sprintf(szRedirect, "Location: http://%s\r\n\r\n", "10.16.50.12:9000/index.asp?page=2");
bflag = true;
}
if(strstr(pMapInfo->pszURL,"3.html"))
{
sprintf(szRedirect, "Location: http://%s\r\n\r\n", "10.16.50.12:9000/index.asp?page=3");
bflag = true;
}
if(strstr(pMapInfo->pszURL,"4.html"))
{
sprintf(szRedirect, "Location: http://%s\r\n\r\n", "10.16.50.12:9000/index.asp?page=4");
bflag = true;
}
if(!bflag)
{
sprintf(szRedirect, "Location: http://%s\r\n\r\n", "10.16.50.12:9000/index.asp?page=1");
}
pCtxt->ServerSupportFunction ( SF_REQ_SEND_RESPONSE_HEADER,
(LPVOID) "302 Redirect",
(DWORD *) szRedirect,
0 );
// Print a message to the debug window
//ISAPITRACE1 ("Redirecting to: %s\n", szRedirect);
// we are done with this request
// return SF_STATUS_REQ_FINISHED_KEEP_CONN;
return SF_STATUS_REQ_HANDLED_NOTIFICATION;
}
// URL did not contain a DoRedirect string.
return SF_STATUS_REQ_NEXT_NOTIFICATION;
}

现在的效果是:我输入:http: //localhost/Index/2.html,网页直接跳转到http://10.16.50.12:9000/index.asp?page= 2,希望的效果是url上显示仍然是我输入的:“http://localhost/Index/2.html”,显示内容为:“http: //10.16.50.12:9000/index.asp?page=2”,应该怎么实现?
os: winxp sp2

解决方案 »

  1.   

    我用的vc++向导作的一个isapi的filter
      

  2.   

    在2.html中,做个iframe,嵌入那个asp页面吧
      

  3.   

    不能更改目标页面,并且2.html这个页面是不存在的。目的就是外面看到用的都是静态页面,很多网站都是这么作的啊。比如 www.Target.com / www.zappos.com等
      

  4.   

    我知道是怎么回事了,在这个方法里面写就是错误的。顶者有分
    解决方法:
    TCHAR url[256],newurl[256];
    DWORD Size=sizeof(url);
    if(pHeaderInfo->GetHeader(pCtxt->m_pFC,_T("URL"),url,&Size))
    {
    //url = _strlwr((char *)url);
    if(_tcsstr(url,_T("/index")))
    {
    if(_tcsstr(url,_T("2.html")))
    {
    _tcscpy(newurl,"/index.asp?page=2");
    }
    else if(_tcsstr(url,_T("3.html")))
    {
    _tcscpy(newurl,"/index.asp?page=3");
    }
    else if(_tcsstr(url,_T("4.html")))
    {
    _tcscpy(newurl,"/index.asp?page=4");
    }
    else 
    {
    _tcscpy(newurl,"/index.asp?page=1");
    }
    pHeaderInfo->SetHeader(pCtxt->m_pFC,_T("URL"),newurl);
    return SF_STATUS_REQ_HANDLED_NOTIFICATION;
    }
      

  5.   

    狂顶楼主,楼主也可用BHO来实现