One of the most important techniques that a web master can use to help make their site more search friendly is to properly implement 301 redirects. 301 redirects can be used to tell a search engine that page “A” is really supposed to resolve to page “B”, or we can even make it so that domain “A” should resolve to domain “B”, if needed. But why should we care about page or domain redirection in the SEO world?

  • Cuts down on duplicate content issues.
  • Helps to transfers link juice into a concentrated areas on your site
  • Helps get your pages indexed
  • Helps your site Rank Better – can brings in more traffic

Here are some apache .htaccess and PHP examples of page 301 redirecting that I’ve used time and time again:

301 Redirct page A to page B

Redirect 301 /old.html

You will also note the “/” before the old.html, which represents your root web directory. The “/” is necessary or your web server will not know where to find the old file. The command also requires you to provide the full URL for the new page.

Redirect page(s) from site A to the same page(s) on site B

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^.*$ [NC]
RewriteRule ^(.*)$$ [L,R=301]

This is a good way of transfering link juice from a domain name that you just bought to another existing domain you already own. The newly purchased site could have many links already built up over time and by properly 301 redirecting all page URLs to your existing site you are better able to take advantage of your purchase. Note that the “.*” on the RewriteCond above which will catch any subdomain such as “www” and redirect that as well to the new domain.

Redirect all domains to a single domain

# Turn on apache mode re-write
Options +FollowSymLinks
RewriteEngine on

# 301 redirect any domain that is not to
# EX: if is requested then it will be redirected to
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

This is good if you have more than one domain name pointing to the same web root directory and want to make sure that all requests to all domains get routed (301 redirected) to a single domain. You may run into this situation if you have a new domain that you want to use in place of your old one but want to transfer all the link juice from the old domain into the new one. Note, this solution doesn’t 301 redirect old page URL’s, it just redirects at the domain level.

non-www to www

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

This 301 redirect can keep your site from tripping duplicate content filters by search engines. Imagine that you did not implement a 301 redirect from non-www to www, then suppose people were to link to a page on your site using non-www and www at the same time from different places… then search engines can get confused as to which URL to throw into their index and since they have 2 URL’s with the exact same content on your site they will see it as duplicate content – and that’s your fault, leading to the engines probably not trusting it = your page’s SERP rankings will drop.

www to non-www

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

Redirect dynamic URL to static looking URL

RewriteRule ^product.php?id=(.*)&category=(.*)$ /$2/newpage.htm [L,R=301]

As an example, here we are redirecting to This kind of 301 redirection is relevant for a lot of shopping cart type web applications that utilize variables in their URL paths. It’s better to leave out unnecessary information in the URL string that a search engine can’t use for indexing – such as an ID of your product or some other random variable specific to the internals of your site that would otherwise mean nothing to human searchers.

Redirect .htm pages to .php pages

RewriteEngine on
ReweiteBase /
RewriteRule (.*).htm$ /$.php

This code can also be used for different page extensions, just replace the htm with your old page extension and replace php with your new page extension.

Redirect all pages in a folder to a single URL

RewriteEngine on
RewriteRule ^oldproduct(.*)$ /new-landing-page.php [L,R=301]

This could be good for example, if you once had a product that you no longer carry but you still want to transfer any link juice from those old pages into another single page somewhere in the local directory.

Redirect page A to page B using PHP

<? Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location:” ); ?>

PHP is nice in that it is a server side language (executed before the HTML is returned to the browser) and you don’t need to mess with your .htaccess file or even have an apache server to 301 redirect using this method.

So that’s it for now. I’m sure there are many other methods or cases where you may want to 301 redirect pages… if so let me know and I’ll add them to this post. Happy 301-ing.

[wpcb id=”1″]


Your email will not be published. Required fields are marked *

redirect htaccess • 11 years ago

Great post. Your content supports and complements my article on 301 & 302 redirects. Keep up the good content.

Read More

Mike Shannon • 11 years ago

Hi Stacey, is there a specific reason you think the runner domain is more search friendly than the milestone one?  And since both domains point to the same content you've got a duplicate content issue.  Best bet is to 301 redirect one domain to the other if you really want to use the runner domain over the other one.  

If you wanted to keep both domains but have the site in question assigned to one domain and build out the other domain with different content then that's also not a bad idea.  You'd just need to get some original content on that new site and build a few links, no need to really submit a sitemap until you have a lot of pages that you feel might not otherwise get indexed.

Read More

SEO Dubai • 11 years ago

I was really confused about the 301 redirect and my site is index without www I want to make with www . This article really helps thanks !

Read More

CRISTOBAL • 11 years ago

You're merging two websites and want to make sure that links to outdated URLs are redirected to the correct pages.
Read More

Other posts you will enjoy...

RelationEdge Announces the Acquisition of Main Path Marketing and Launch of a Full-Service Marketing Cloud Practice
Twitter Moments – Should They Be a Part of Your Social Media Strategy?
Developing a Plan for Social Live Video
4 Common Email Problems and How to Solve Them