我作了一个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
//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
解决方案 »
- 基于MFC的多文档应用程序、选择了office风格(即Ribbon界面)后,属性页
- fatal error LNK1104: cannot open file "cxcore.lib"
- CWND派生类添加CDIALOG
- windowsAPI polyline 问题
- 有关函数模板使用的问题。想不通,实在想不通!
- 请教怎么用c,c++开发语音传输
- 建议csdn成立一个程序员工会,保障所有中国程序员的权益,支持的顶一下
- 我想问下程序启动进入主界面时会发出“当”的一声,有点像VC编译时发出的那种声音,可能是什么原因?
- 在VC中用几张图片实现动画,要用到哪些原理及函数!
- win32 SDK菜鸟级别问题!
- 一个文本框的问题请大家帮忙.说简单也难,说难也简单.
- 求文件传输dll
解决方法:
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;
}