Optify Help/Frequently asked questions/Pages and links

How to implement a 301 redirect

Jay French
posted this on June 16, 2010 01:54 pm

 

301 redirects are used for two main purposes: to permanently redirect web traffic from an old address to a new address in a way that preserves links, and to "canonicalize" URLs.  To canonicalize a URL is to redirect all equivalent variations to a single, "canonical" URL, which can improve your website's performance in some search engines.  If you are using an Apache Unix server, the procedure below gives you an easy way to do this:

How to canonize your root URL using .htaccess and apache

    1. Log on to your web site (you must have admin privileges to make these changes.)
    2. Go to the root directory of your website, and locate the .htaccess file (there may be others in other directories, but the one in the root directory is the one you want.)
    3. Open the file in a UNIX-style text editor (not Notepad).
    4. Add the following lines to the file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC]
RewriteRule (.*) http://www.yourdomain.com/$1 [L,R=301]

In lines 2 and 3, replace "yourdomain" with the host name for your website (e.g. "NewNowNet" if your domain name is "NewNowNet.com").

  1. Save the file.
  2. Test your changes by typing a non-canonical version of your URL into your browser (e.g. "www.newnownet.com/index.htm"). If redirect is working, you will see the URL automatically change to the canonical version in your browser address bar.

 

Here are some resources for more information on using 301 redirects:

SEOmoz | YOUmoz - A Simple Guide to .htaccess

SEOmoz | Guide to Applying 301 Redirects with Apache