Welcome to WebmasterWorld Guest from 34.238.189.171

Forum Moderators: ocean10000

Message Too Old, No Replies

Please Help! ASP.NET Dynamic Page Redirect

Need help with 301 redirect for certain ID

     
12:14 am on Dec 23, 2007 (gmt 0)

New User

10+ Year Member

joined:Dec 22, 2007
posts: 1
votes: 0


Somehow Google indexed an incorrect URL www.mydomain.com/some_directory/another_directory/file_name.aspx?id=97

The correct URL that should be indexed is www.mydomain.com/some_directory/another_directory/file_name.aspx?id=97&some_parameter=some%20variable%20stuff

Since the id is the same, all the page content is the same for both URL's. Google probably has multiple URL's for the same content indexed, so to avoid a duplicate content issue and be sure all the link equity (both externally and internally) is flowing to just one version of the page we want indexed, we need to do a 301 redirect of any URL's in this form:

www.mydomain.com/some_directory/another_directory/file_name.aspx?id=97

Or

www.mydomain.com/some_directory/another_directory/file_name.aspx?id=97&some_parameter=some%20incorrect_variable%20stuff

To the correctly formatted URL of:

www.mydomain.com/some_directory/another_directory/file_name.aspx?id=97&some_parameter=some%20variable%20stuff

I assume we need to install a ASP.NET script of some sort on file_name.aspx. Does anybody have that script handy or know of any kind of solution?

I am not a programmer, so sorry if my question and explanation does not use the correct terminology. I really appreciate any help any body may have.

5:36 pm on Dec 24, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:733
votes: 0


Here is a simple way to do it, you will need to adapt it to match exactly what you need, but the basic idea is there.


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim myID As Integer
Dim myParameter, myCorrectParameter, myNewURL As String

' Get the Query String values
myID = Request.QueryString("id")
myParameter = Request.QueryString("some_parameter")

If myParameter <> "WhateverYouExpected" Then
myCorrectParameter = "WhateverItShouldBe"
myNewURL = String.Format("www.mydomain.com/some_directory/another_directory/file_name.aspx?id={0}&some_parameter={1}", myID.ToString(), myCorrectParameter)
Response.Status = "301 Moved Permanently"
Response.AddHeader("Location", myNewURL)
Else
' do whatever You would have done otherwise
End If
End Sub
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members