Last post Apr 18, 2013 02:59 PM by stockcer
Apr 18, 2013 02:30 PM|rspiet|LINK
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.
For instance if user types in http://mywebsite/PageOne.aspx?QVar=x, I want IIS to redirect to
Apr 18, 2013 02:44 PM|stockcer|LINK
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"
or a variation there of. There are other options as well.
Apr 18, 2013 02:52 PM|rspiet|LINK
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.
Apr 18, 2013 02:59 PM|stockcer|LINK
try this site for some options.