c++ - IIS 6 Isapi filter - forward or redirect requets to other domain -


a code bellow main part of isapi filter iis 6. need redirect request contains "/some_string" other url, lies on other domain , other server. how it?

dword camgnisapifilter::onpreprocheaders(chttpfiltercontext* pctxt,     phttp_filter_preproc_headers pheaderinfo) {     char buffer[256];     dword buffsize = sizeof(buffer);     bool bheader = pheaderinfo->getheader(pctxt->m_pfc, "url", buffer, &buffsize);      cstring urlstring(buffer);     urlstring.makelower();      if (urlstring.find("/some_string") != -1) //we want redirect file     {         urlstring.replace("/some_string","");         urlstring = "http://new_domain.cz/something" + urlstring;          char * newurlstring= urlstring.getbuffer(urlstring.getlength());         pheaderinfo->setheader(pctxt->m_pfc, "url", newurlstring);         return sf_status_req_handled_notification;     }     //we want leave alone , let iis handle     return sf_status_req_next_notification; }

thanks!

you need respond 302 status code, telling browser new url want redirect to.

just small, not production-grade template achieve this:

//... char rsp[50]; wsprintf(rsp, "location: %s\r\n\r\n", newurlstring); pfc->serversupportfunction (pfc, sf_req_send_response_header, (pvoid) "302 redirect", (dword) rsp, 0); //...

instead of

pheaderinfo->setheader(pctxt->m_pfc, "url", newurlstring);

i think thing have do.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -