301 Vs 302 – Know Your Redirects!

301 Vs 302 – Know Your Redirects!

Redirection is when you forward one URL to another. There are a few different sorts of redirects – the main two being 301 and 302.

301 – Content has moved permanently

A 301 redirect is a permanent redirect which manages to retain up to 99% of the ranking power or link juice to the newer page. 301 is the HTTP status code for this sort of redirect.

302 – Content has moved temporarily

A 302 is a found or temporary redirect. It passes no link juice.

Let’s say you have to redirect to another address permanently. There are a few options for doing this, but the best way is a 301 redirect. This is because it’s best for both users and for search engines. Google will see that the link juice needs to be squeezed from the new page and not the old one.

It can take time for search engines to see the 301 and credit the page with the previous page’s trust and ranking.

Adding 301 redirects to the PHP code in the header function is the easiest way to do this. You can use the apache module mod_rewrite to match specific patterns for entire folders to allow you to redirect to new URLs without going through each and every page to add PHP script.

Most web servers have the apache module mod_rewrite installed by default. This operates in either per-server or per-directory context. Per-server context means that a dev will have to edit the httpd.conf configuration file; the per-directory uses .htaccess files.

To redirect files or folders from one domain to another, devs will need to add this directive:

RedirectMatch 301 /seo/(.*) /£1

…to the right file in the server. This tells apache to match the seo folder followed by zero. Putting the .* in brackets tells it to save the matched string as a back reference. This is placed at the end of the URL, in this case £1.

This method ensures that any redirects save the SEO power of the original pages.


Image credit, Christine Johnstone http://www.geograph.org.uk/photo/2078719