Tue 16 Jan 2007
Many a times you need to move or rename some of your pages for some reason , if you are utilizing .asp (Windows Active Server Pages) as the underlying technology for your website, then there is a simple 301redirect method that you can utilize for changing URL name.This 301 method allows you to implement a Permanent move/rename of your webpages.
Implementation :
Consider a page named old-page.asp that is to be renamed or to new-page.asp, firstly remove all of the code of that page and place the code given below in that old page.
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "http://www.yoursitename.com/new-page.asp"
%>
In the above 301 redirect example, you need to change the Location to the URI of your new page. Include the full URI path unless you are redirecting to a root level page (index.asp, default.asp, etc.). If you are setting up a 301 redirect for a root level page, keep the URI short and without the index.asp file name.
for example… “Location”, “http://www.yoursitename.com/sub-directory/”
Once you’ve included the above code at the top of your old-page.asp, you should crosscheck that it is returning the proper server header response using tool to check Server header content.
Doing so, we instruct the spiders to update their index and replace the old URI (old-page.asp) with the new URI (new-page.asp).
After applying 301 redirect you should not be able to browse to the old-page.asp (unless you have auto redirects turned off in your browser).
Always keep you old url (www.yoursitename.old-page.asp ) in place for sometime and include a message which will alert visitors about redirection and of new url and request them to update their bookmark as per new url .
3 Responses to “301 Redirect in ASP”
Leave a Reply
You must be logged in to post a comment.



















January 18th, 2007 at 10:04 am
Is this same way applicable for both classic ASP and ASP.NET?
January 18th, 2007 at 10:59 am
Paul,
Above mentioned code was for classic ASP and for deploying 301 redirect using ASP.NET you will have to modify your code to some extent :
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(”Location”,”http://www.new-url.com/”);
}
January 18th, 2007 at 12:02 pm
Thanks for help!