Content rewriting, drupal and web page redirection

Rewriting content, reorganizing content or updating the file names of pages of a website can happen over time. It is almost a given that pages or structure or even the Content Management System of a website can change. It is really not a big deal. Not redirecting your indexed pages on the search engines however is a very big deal! With drupal it takes a little investigation to get it right.

I actually have changed the structure of my site and I had to figure out how to properly set up directs. Drupal is the CMS of my choice and has been for a long time but that is another story.

A drupal installation comes with standard url rewrites so that a page named like http://www.jasperkooij.com/?q=node/16 can be turned into a url like http://www.jasperkooij.com/drupal/drupal-installation/installing-drupal.htm. So I'm using the example of telling the search engines that my indexed page mentioned above, now has a new location. This can be done with a little trick called redirecting. There are 2 types of redirecting:

  • A 302 redirect which is used when the page exists but is under a different URL only temporarily. Realistically, this does not happen very often.
  • The 301 redirect is a permanent redirection. The page referenced has moved permanently and search engines should update their information for this particular URL.

For more in-depth information visit Matt Cutts' article on [weblink:31|SEO advice: discussing 302 redirects].The whole rewrite engine is directed by a file called ".htaccess" and this file is sitting on the root folder of your website.

Look for this section in your .htaccess file:


----------------------------------------------------------------------------------------------------------------

# Modify the RewriteBase if you are using Drupal in a subdirectory and

# the rewrite rules are not working properly.

#RewriteBase /drupal


----------------------------------------------------------------------------------------------------------------


before the next section start ( # Rewrite old-style URLs of the form 'node.php?id=x'.)


insert this new section:

----------------------------------------------------------------------------------------------------------------
#custom redirects

RewriteRule ^node/16$ http://www.jasperkooij.com/drupal/drupal-installation/installing-drupal.htm [R=301,L]

#end custom redirects

----------------------------------------------------------------------------------------------------------------


This, I have found works great and creates a very clean redirect to the new page. So check your website traffic reports for 404 errors and simple update your .htaccess file