I am using Windows 2008 Server with IIS7. Users sometimes enter a specific non-existent link on my web site. I would like all requests to this sepcific link to be redirected to another page, complete with the query string variables being passed.
there are several ways to do this but the one to use is the following in your global.asax
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs)
If HttpContext.Current.Request.Url.AbsoluteUri.ToLower().StartsWith("http://mywebsite/PageOne.aspx?QVar=x") Then
Dim newUrl As String = HttpContext.Current.Request.Url.AbsoluteUri.ToLower().Replace("http://mywebsite/PageOne.aspx?QVar=x", "http://mywebsite/PageTwo.aspx?QVar=x")
Response.Status = "301 Moved Permanently"
Response.AddHeader("Location", newUrl)
End If
or a variation there of. There are other options as well.
Thank you, but I was trying to see if this could be done in IIS. Making a change to the actual web site code in my company is a bureaucratic nightmare.
I was hoping that there was a way to do this just in IIS.