kwilliams
11-12-2007, 11:50 AM
I have an old ASP site, and I've created a new ASP.NET site. I'm trying to set up an auto-redirect on each of the old ASP pages that will:
1) Tell the search engines that the URL has permanently moved
2) Redirect the user to the new URL after a 5 second delay, so that they can see a note about the change
I've found a few articles on how to properly do this at:
http://blogs.msdn.com/samar/archive/2005/06/07/425963.aspx
http://www.webdeveloper.com/forum/archive/index.php/t-11443.html
http://forums.aspfree.com/asp-development-5/delay-response-redirect-141800.html
And this is what I've come up with:
<%@LANGUAGE="JAVASCRIPT" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
Response.Buffer = true;
//Declare variables
var strOldURL = "oldpage.asp";
var strNewURL = "newpage.aspx"
//Update search engines
Response.Status = "301 Permanently Moved";
//Redirect to new page in 5 seconds
//Response.AddHeader("REFRESH", "5;URL=" + strNewURL);//NOT WORKING IN IE - LIVE
%>
<html>
<head></head>
<body>
<h2>The Page Cannot Be Found</h2>
<br />
The page you are looking for has moved.
<br />
<br />
<strong>Old Location: </strong><%=(strOldURL)%>
<br />
<strong>New Location: </strong><a href="<%=(strNewURL)%>"><%=(strNewURL)%></a>
<br />
<br />
You will be redirected to the new page in 5 seconds. Please correct any broken bookmarks.
</body>
</html>
This solution works fine in Firefox, but not in IE6 or IE7 (The page cannot be displayed). One of the articles noted that the "Response.AddHeader" is controlled by the browser, so it won't alway work. But I don't know of another way to create a delay within an ASP page using JavaScript syntax. Also, I've seen "301 Moved Permanently" and "301 Permanently Moved" used in several examples, but I don't see which of these is proper...or will they both work fine? If anyone can let me know what I'm doing wrong, that would be great. Thanks.
1) Tell the search engines that the URL has permanently moved
2) Redirect the user to the new URL after a 5 second delay, so that they can see a note about the change
I've found a few articles on how to properly do this at:
http://blogs.msdn.com/samar/archive/2005/06/07/425963.aspx
http://www.webdeveloper.com/forum/archive/index.php/t-11443.html
http://forums.aspfree.com/asp-development-5/delay-response-redirect-141800.html
And this is what I've come up with:
<%@LANGUAGE="JAVASCRIPT" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
Response.Buffer = true;
//Declare variables
var strOldURL = "oldpage.asp";
var strNewURL = "newpage.aspx"
//Update search engines
Response.Status = "301 Permanently Moved";
//Redirect to new page in 5 seconds
//Response.AddHeader("REFRESH", "5;URL=" + strNewURL);//NOT WORKING IN IE - LIVE
%>
<html>
<head></head>
<body>
<h2>The Page Cannot Be Found</h2>
<br />
The page you are looking for has moved.
<br />
<br />
<strong>Old Location: </strong><%=(strOldURL)%>
<br />
<strong>New Location: </strong><a href="<%=(strNewURL)%>"><%=(strNewURL)%></a>
<br />
<br />
You will be redirected to the new page in 5 seconds. Please correct any broken bookmarks.
</body>
</html>
This solution works fine in Firefox, but not in IE6 or IE7 (The page cannot be displayed). One of the articles noted that the "Response.AddHeader" is controlled by the browser, so it won't alway work. But I don't know of another way to create a delay within an ASP page using JavaScript syntax. Also, I've seen "301 Moved Permanently" and "301 Permanently Moved" used in several examples, but I don't see which of these is proper...or will they both work fine? If anyone can let me know what I'm doing wrong, that would be great. Thanks.