How to: Response Redirct to the Friendly URLs

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
 
G

Guest

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>");
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top