301 Redirect
The 301 redirection is described in RFC2616: “The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs”.
Browsers automatically follow these redirections. They also display the new permanent address in the address bar.
In accordance with RFC2616, the same address pointed to by the redirection will eventually be saved in the browser favorites.
The standard recommends to use a 301 redirect when a page has been permanently moved to a new address.
301 Redirect and Search Engines
Â
According to RFC2616, search engines should forget the redirecting address and save the address pointed to by the redirection as the preferred address.
When a page has been moved to a permanent new address, Google recommends to use a 301 redirect. But, strangely enough, the leading search engine often needs weeks or months to take this information into account in its search results.
301 Redirect Implemented in .htaccess File
Â
Assuming the web server allows it, it is easy to implement a 301 redirect in .htaccess.
Moving a page
RedirectPermanent /old-file-name.html http://www.new-domain.com/new-directory/new-file-name.htmlMoving a directory
RedirectPermanent /old-directory http://www.new-domain.com/new-directoryMoving an entire site
RedirectPermanent / http://www.new-domain.com/
301 Redirect Implemented in a Server Script
Â
The script (typically a PHP, Perl or ASP program) will have to generate a 301 header.
Moving a page in PHP
<?php
header(“Status: 301 Moved Permanently”, false, 301);
header(“Location: http://www.new-domain.com/new-directory/new-file-name.html”);
exit();
?>
Checking if a 301 Redirect Works
Â
InternetOfficer has designed a free on-line tool to check the working of redirects. This new tool to check redirects analyses the HTTP-header and the page contents and identifies in seconds 301 and 302 redirects and HTML redirects (meta refresh).
August 25th, 2007 at 12:42 am
I started a thread few days ago on the HTTP Error (status) codes at WebMasterWorld and I got some good replies that are worth reading related to your article. Not based on specs but on user experiences.
http://www.webmasterworld.com/google/3430126.htm
December 17th, 2007 at 12:40 pm
I would also like to add that 301 redirect in the .htaccess file can be implemented as follows:
redirect 301 /old-file-name.html http://www.new-domain.com/new-directory/new-file-name.html
Apart from this, we could also use rewrite (also sending a 301 status):
RewriteEngine On
RewriteRule ^olddir/(.*)$ http://www.new-domain.com/newdir/$1 [R=301,L]
February 12th, 2008 at 2:23 am
is there a way to 301 redirect in iis only with ftp and without any access to the server admin.
February 12th, 2008 at 8:39 am
You can put this code in the pages to be redirected:
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "http://www.example.com/new_url"
%>
or
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently" ;
Response.AddHeader("Location","http://www.example.com/new_url") ;
}
</script>
Jean-Luc
March 20th, 2008 at 7:43 pm
Hi, the previous webmaster for a site I’m working on had a bunch of files named in French with accents. I renamed those in order to take them out. Unfortunately, google still manages to see the old pages and they lead to a 404 error.
I’ve created a .htaccess file to redirect quite a few pages but I’m having some issues with those files in particular.
i.e: I renamed a file previously named “série.pdf” to “serie.pdf”
Google sees the “série.pdf” as something like this “S%C3%89RIE.pdf” and I think that is where the problem lies…
My redirect line goes something like this:
redirect 301 /images/brochures_fr/S%C3%89RIE.pdf
http://mywebsite.com/redirect/images/brochures_fr/SERIE.pdf
Unfortunately, it doesn’t seem to work.
If you could provide me with any input or suggestions, I’d greatly appreciate it.
Thank you for your time.
Sincerely,
Ong Gia
March 20th, 2008 at 9:03 pm
Try this:
redirect 301 /images/brochures_fr/SÉRIE.pdf
http://mywebsite.com/redirect/images/brochures_fr/SERIE.pdf
May 30th, 2008 at 9:00 pm
The question sometimes arrises with clients “How permanent is a 301 permanent redirect?” Anotherwords, if at some future point, the client changes their mind for whatever reason, what are the consequences of changing a “permanent” redirect?
May 31st, 2008 at 10:29 pm
Let say you have a permanent redirect from A to B.
As long as there are still links pointing to A, Googlebot will continue to crawl A from time to time. If, at some point, the redirect to B disappears or if it is replaced by another redirect, Google will know it as soon as A has been crawled. This means that after a transition period, B will lose the benefits from the redirect from A.
June 16th, 2008 at 3:54 pm
how to redirect a htm site to php dynamic site ?
July 5th, 2008 at 9:11 am
thank you for this tip and the 301 checking tool this will come in useful
August 11th, 2008 at 5:52 pm
I am trying to use:
ReDirect 301 /docs/file%20name%20with%20spaces.pdf
http://www.example.com/newdir/filenamewithoutspaces.pdf
but am having similar problems as Jean-Luc with his accent. How can I get around this as I believe the syntax for ReDirect does not permit quotes around the text.
August 11th, 2008 at 7:44 pm
Just use the quotes (they are permitted):
ReDirect 301 "/docs/file name with spaces.pdf"
http://www.example.com/newdir/filenamewithoutspaces.pdf
August 12th, 2008 at 2:04 pm
Hello Thanks… It will help me lot
December 10th, 2008 at 11:08 pm
I’m having a lot of trouble getting this to work. I want all of my http://signsmanufacturing.com queries to go to http://www.signsmanufacturing.com
I’ve tried the following, but it doesn’t work:
RedirectPermanent http://signsmanufacturing.com http://www.signsmanufacturing.com
What gives?!?