Forum Moderators: open

Message Too Old, No Replies

301 Moved Permanently

Simple redirect for asp pages.

         

pageoneresults

3:35 pm on Dec 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



For those of you who have .asp pages sitting out there and need a quick way to set up a 301 Moved Permanently server header response, you can place this code above your opening <html> tag or before the first tag on the page (you could have a DOCTYPE present and this code needs to go before the DOCTYPE)...

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

You would of course need to change the Location to your new URI. This script would be used if you are moving a page or renaming a page and wish to alert the spiders that the page has been 301 Moved Permanently. You would also need to place a message on that page for the visitors telling them that the resource has been moved and provide them with the new URI too.

There are other ways to do this, this makes it simple for those who are not managing hundreds or thousands of pages that require a 301 Moved Permanently server header response.

Note: This technique only works with .asp pages.

Make sure to check that your pages are returning the proper server header response...

Server Header Checker [searchengineworld.com]

korkus2000

10:21 pm on Dec 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To add to your thread page1 here is the ASP.Net version:

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.example.com/");
}
</script>

pageoneresults

10:45 pm on Dec 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks korkus, I'm going to add that to my snippets library. I've not worked with asp.net yet but, I'm sure that will come in handy.

[edited by: pageoneresults at 10:51 pm (utc) on Dec. 18, 2003]

macrost

10:48 pm on Dec 18, 2003 (gmt 0)

10+ Year Member



Why use a 301? Is it faster for search engines compared to a 404?

Mac

pageoneresults

10:49 pm on Dec 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



404 is for a Page Not Found error. 301 is for a page that has been Moved Permanently and you want the spider to update its index.

If you've moved or renamed a page, then a 301 is in order. If you removed a page and there is no replacement, then a 404 is in order.