301 Redirects

Redirecting a website or webpage can be important for a number of reasons, site redesign, change of domain name, business rebranding etc.As far as the search engines are concerned there should only ever be one form of redirect, and that is via the “301? method. Any other form of redirect is considered bad form and will most likely cause all sorts of issues in search results.

The way you actually carry out a 301 redirect depends on the server you have (either windows or Linux) and the type of redirect you need.

Redirecting with the .htaccess file

If you are running Linux on your server you should use the .htaccess method. To create a canonical redirect (ie http://example.com to http://www.example.com or vice versa) you need to add the following to your existing .htaccess file, or if one doesn’t exist create one and add the code:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]

If you want to redirect one domain to another you can use the following code:

redirect 301 / http://www.newdomain.com/

To redirect pages the method used depends if you are redirecting static pages or dynamic ones, the code for either are shown below.

To redirect a static page:

redirect 301 /oldpage.htm http://www.example.com/newpage.htm

To redirect a dynamic page you need to put in the following:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=**$
RewriteRule ^/page.php$ http://www.example.com/newname.htm? [L,R=301]

The id=** is the query string and the page.php the name of the file immediately prior to the query.

301 Redirects using IIS

If you are on a windows server you will need to use IIS (internet information services) to perform 301 redirects, and it is just done the same way regardless of which version of Windows server you use. To carry out a 301 you need to do the following:

In internet services manager, right click on the file or folder you wish to redirect
Select the radio titled “a redirection to a URL”.
Enter the redirection page
Check “The exact url entered above” and the “A permanent redirection for this resource”
Click on “Apply”

And it’s as simple as that, job done.