How to: Response Redirct to the Friendly URLs

  • Thread starter Thread starter Showjumper
  • Start date Start date
S

Showjumper

I have set up an HttpModule that creates friendly urls and utilizes
RewritePath. Such a url looks like
/articles/The-Article-Title-Goes-Here.aspx. I onlu recently added the
httpmodule so many of the search engines still have links that point to urls
with querystrings - /articles/displayarticle.aspx?ArticleID=10 for example.
What i want to do is redirect from this latter url to the newer user
friendly url. Any ideas. So far my attempts with and HttpModule for
redirecting have failed i FireFox i get the dreaded The Page Is not
redirecting properly message.

Thanks
Ashok Padmanabhan DVM
 
You could try something along this line:
// usage: SafeRedir("http://my-friendly-url");

void SafeRedir(string URL)
{
Response.Buffer = true;
Response.Status = "302 Object moved";
Response.AddHeader( "Location", URL );
Response.Write ("<HTML><Head>");
Response.Write ( "<META HTTP-EQUIV=Refresh CONTENT=\"0;URL=" + URL + "\">");
Response.Write ( "<Script>window.location='" + URL + "';</Script>" );
Response.Write("</Head>");
Response.Write ("<Body> This page was moved <A Href=\"" + URL +
"\">here</A>");
Response.Write("</HTML>");
}
 
Back
Top