views:

84

answers:

3

Hello,

I upgraded my site from asp to asp.net. This means that all of my previous asp files became obsolete. I don't want to lose my Google Ranking of the old pages.

What is the proper way to redirect? I tried to catch all of the old asp pages is my 404 and then to:

if Request.QueryString("aspxerrorpath").contains("index.asp") = true then 
  Response.Status = "301 Moved Permanently"
  Response.AddHeader("Location", "http://www.domain.com/index.aspx")
  Response.Redirect("/index.aspx")
end if

but it doesn't catch asp pages, only aspx.

A: 

Assuming that you're running IIS7, there is a rewrite module available that you can use. This allows you to match a URL and redirect it to another one. Something like ^(.+)\.asp$ as pattern and {R:1}.aspx as rewrite URL should do it.

Daniel Egeberg
A: 

You can do it in your global.asa file.

404 errors for ASP files will still call the 'application'. On Application start, you can redirect to the the appropriate aspx file.

global.asa:

Sub Application_OnStart
    'Get page name from request and redirect accordingly
    '...
End Sub
Ed B
A: 

I generally replace the contents of the asp page with the following:

<%@ Language=VBScript %>
<%
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.domain.com/index.aspx"
Response.End
%>
James O'Sullivan
not the most technical of solutions, but its quick and easy
James O'Sullivan