many_tentacles
06-25-2009, 10:33 AM
Hi
I have several URLs pointing to the same folder in IIS. However, I want to create 301 redirects so that no matter what URL is visited, you end up at the same site.
I have managed it with 302 redirects (see the code below) but this is not ideal from an SEO point of view. Is there any way of doing this with .net rather than having to create separate sites in IIS.
Thanks
<%@ Page Language="VB" Debug="true" %>
<script runat="server">
Dim strRemote As String
'***********************************************************
Sub Page_Load()
'***********************************************************
strRemote = Request.ServerVariables("HTTP_HOST")
Select Case strRemote
'- - - - - - - - - - - - - - - - - - -
Case "www.myurl1.co.uk"
Response.Redirect("http://www.myurl2.co.uk")
'- - - - - - - - - - - - - - - - - - -
Case "www.myurl2.co.uk"
Session("mysession") = "true"
'- - - - - - - - - - - - - - - - - - -
End Select
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>My Page</title>
</head>
<body>
<%= Session("mysession") %>
</body>
</html>
I have several URLs pointing to the same folder in IIS. However, I want to create 301 redirects so that no matter what URL is visited, you end up at the same site.
I have managed it with 302 redirects (see the code below) but this is not ideal from an SEO point of view. Is there any way of doing this with .net rather than having to create separate sites in IIS.
Thanks
<%@ Page Language="VB" Debug="true" %>
<script runat="server">
Dim strRemote As String
'***********************************************************
Sub Page_Load()
'***********************************************************
strRemote = Request.ServerVariables("HTTP_HOST")
Select Case strRemote
'- - - - - - - - - - - - - - - - - - -
Case "www.myurl1.co.uk"
Response.Redirect("http://www.myurl2.co.uk")
'- - - - - - - - - - - - - - - - - - -
Case "www.myurl2.co.uk"
Session("mysession") = "true"
'- - - - - - - - - - - - - - - - - - -
End Select
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>My Page</title>
</head>
<body>
<%= Session("mysession") %>
</body>
</html>