There are no comments yet...Kick things off by filling out the form below.
HTTP response status codes 301 and 302 are used to indicate the browser that the requested page (URL) is to be found at another location. The 301 Moved Permanently status code tells the browser just that : the web page has been moved to another location permanently. This also tells search engine to remove to old URL from their index and to replace it with the new one.
The 302 Found status code tells the browser that the document has been found but redirects the browser to another location to get its content. In this case, search engines may have different behaviors. Perhaps you may want to read this article from Matt Cutt on the subject.
In this tutorial, I will show you multiple ways of creating a redirect.
Assuming your website is hosted on a Apache web server :
301 Redirect:
redirect 301 /oldpage.html http://www.new-url.com/newpage.html
302 Redirect:
redirect /oldpage.html http://www.new-url.com/newpage.html
301 Redirect:
Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http://www.new-url.com/newpage.html” );
?>
302 Redirect:
header(”Location: http://www.new-url.com/newpage.html”);
exit();
?>
301 Redirect:
<script runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(“Location”,”http://www.new-url.com”);
}
</script>
302 Redirect:
<script runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “302 Found”;
Response.AddHeader(“Location”,”http://www.new-url.com”);
}
</script>
301 Redirect:
def old_action
headers["Status"] = “301 Moved Permanently”
redirect_to “http://www.new-url.com/”
end
302 Redirect:
def old_action
headers["Status"] = “302 Found”
redirect_to “http://www.new-url.com/”
end
Of course there are even other ways of performing redirection, for instance using IIS but that’s for another post.
Stay tuned!
There are no comments yet...Kick things off by filling out the form below.
| 1 | Hostpapa - £ 1.95 |
| 2 | UK2NET - £ 3.95 |
| 3 | Clook - £ 5.00 |
| 4 | WebHosting.uk.com - £2.29 |
| 5 | Just Host - £3.45 |
| 6 | 1and1 - £ 2.49 |
| 7 | Webfusion - £3.95 |
| 8 | FastVision - £1.49 |
| 9 | Heart Internet - £2.49 |
| 10 | FastHosts - £ 3.49 |