301 Redirects With Drupal .htaccess

Below are some tips to help make your Drupal Content Management System driven website more Search Engine friendly using the .htaccess file.  Your .htaccess file is located in the root of your Drupal installation.  This file is only used on Apache server.

Creating a 301 (Permanent) Redirect Using the .htacess File

301 or permanent redirects are useful if the content of your website has permanently moved to a new URL.  This happens more often than you might imagine and a 301 redirect is a great way to send users unkowingly to the new location and to notify Search Engines of the new location of old content.  This way you will keep your Page Rank and Search Engine standing while allowing your URL to change.  If you do not use some sort of redirect then your old URL will still appear in searches sending users to a 404 File Not Found page, thus having your URL disappear from the results not to mention frustrating potential customers.

To create a 301 redirect using your .htaccess file find the following section of your file:

  # Modify the RewriteBase if you are using Drupal in a subdirectory and
  # the rewrite rules are not working properly.
  #RewriteBase /drupal

Below this you may add as many 301 redirects as you like on new lines.  The code for a 301 redirect is as follows:

  RewriteRule ^old_file_name http://www.example.com/new-file-name [R=301,L]

Replace old_file_name with the path to the old file which you wish to have redirected and then replace http://www.example.com/new-file-name with the complete path to the new page.

-----------

This Drupal tutorial was added by Simon Vreeswijk of Stikky Media Internet Marketing in Victoria, BC.