Hello,
I have questing about redirect. My company ask me to make redirect for the corporate website from “Domain.com” to “www.domain.com”
I was able to do this with the code bellow.
Here is my question:Code:Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
' Fires at the beginning of each request
Dim strRedirectToWWW As String
Dim bAdminURl As Boolean = False
strRedirectToWWW = ConfigurationSettings.AppSettings("RedirectToWWW")
'For testing set RedirectToWWW to false
If strRedirectToWWW.Trim.ToLower = "true" Then
Dim sOldPath As String = Request.Url.ToString.Trim.ToLower
Dim sNewPath As String = ""
If sOldPath.IndexOf("www.") = -1 Then
sNewPath = sOldPath.Replace("Domain.com", "www.Domain.com")
Response.AddHeader("Location", sNewPath)
Response.RedirectLocation = sNewPath
Response.Status = "301 Moved Permanently"
Response.StatusCode = 301
Response.Redirect(sNewPath)
End If
End If
End Sub
When I redirect website “http://Domain.com” to “http://www.Domain.com” the end result looks like this “http:// www.Domain.com/index.aspx”.
I there a way to remove “Index.apsx” form URL during redirect?
I want my end result from redirection look like this “http://www.Domain.com/”
Thank you.
P.S. I'm using .NET Framework 1.1
