Set up 301 redirects from old classic ASP pages to new ASP.NET webforms pages

22,116

Solution 1

Just place this at the top of your page before any output:

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.example.com/new-url"
%>

Don't put any response.redirects below this code.

Solution 2

Simple add at the beginning of your asp pages the move command:

<%
   Response.Status="301 Moved Permanently"
   Response.AddHeader "Location","http://www.example.com/newpage.aspx"
   Response.End
%>

This is the idea, now if you have one to one rename, and only the aspx change, you can make a simple asp script that read the currency page and make the final redirect string.

Solution 3

As a sub if anyone wants

sub RedirectPermanently(url)
    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location",url
    Response.End
end sub
Share:
22,116
Leah
Author by

Leah

Updated on April 20, 2020

Comments

  • Leah
    Leah about 4 years

    I've finished developing a website using ASP.NET Webforms and to finish it off I'm in the process of setting up some 301 redirects to ensure the old site's links are redirected properly.

    However, the old website was written in classic ASP. What is the best way to set up redirects from old .asp pages to new .aspx pages? (Note: I don't have control over the server the website is being hosted on so I can't do anything in IIS)