urlmap的简单问题,在线送分

angle1219 2006-11-02 09:29:36
我作了一个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
...全文
189 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
LiChenYue 2006-12-02
  • 打赏
  • 举报
回复
看不太懂,还是顶了,蹭点分
desger 2006-12-02
  • 打赏
  • 举报
回复
我也看冬了,呵呵,顺便接分
baojian88888 2006-11-02
  • 打赏
  • 举报
回复
在2.html中,做个iframe,嵌入那个asp页面吧
angle1219 2006-11-02
  • 打赏
  • 举报
回复
我用的vc++向导作的一个isapi的filter
yjgx007 2006-11-02
  • 打赏
  • 举报
回复
你用的是异步插件还是BHO?
astrony 2006-11-02
  • 打赏
  • 举报
回复
狂顶楼主,楼主也可用BHO来实现
angle1219 2006-11-02
  • 打赏
  • 举报
回复
我知道是怎么回事了,在这个方法里面写就是错误的。顶者有分
解决方法:
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;
}
angle1219 2006-11-02
  • 打赏
  • 举报
回复
不能更改目标页面,并且2.html这个页面是不存在的。目的就是外面看到用的都是静态页面,很多网站都是这么作的啊。比如 www.Target.com / www.zappos.com等

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧