Drupal SEO Tutorial: How to Set Up 301 Redirects

 

Changing your website URLs can cause problems: people who bookmarked the page can’t find it again, search engines are baffled when your content is now missing, and people or websites that link to your pages now have broken links. Not good problems to have with your website content.

You would think that the best advice, then, would be to never change your URLs. The reality is, however, that there are many legitimate reasons that a URL needs to be changed:

  • Companies acquire websites and need to move content.
  • Products become obsolete so the content needs to move to a different section of the site.
  • Keywords change so content that was relevant before doesn’t fit.

Thank the search engines we have redirects.

Redirects came into being because webmasters needed a way to let visitors and search engines know that content has been moved from its original home to another place on the server. Simply put, a redirect tells a browser to go to another page when the content has been moved.

For example, if you want people who visit:

www.yourDrupalsite.com/ties-paisley/calvin-klein

to automatically move on to:

www.yourDrupalsite.com/ties/paisley/calvin-klein

This helps maintain a clean site that doesn’t turn into a mess when content gets moved around.

301 Redirects - The Correct Way to Move Content Around

A few years ago, you might have created a path to your content that looked like this:

http://www.yourDrupalsite.com/ties-paisley/calvin-klein

But now, you realize that it is better to have a path to your content like this:

http://www.yourDrupalsite.com/ties/paisley/calvin-klein

Good thing you’re using Drupal because this is easy to do.

The actual content sits at a node reference location; for example, node/123. So you just have to create a new alias, right? Not so fast, hot shot!

Although it is possible to assign multiple aliases to a node, this is probably not a good idea from an SEO perspective. If Google sees two identical pages on your website, they’re not going to know which one is the most important. In the best case, your pages will actually compete with each other in Google for the top spot. In the worst case, Google might think you’re trying to spam your way to the top and penalize your site. Never a good outcome for your Drupal SEO.

However, if you simply delete the old URL then you have a situation where someone who may have bookmarked the old location will now get a 404 - Page Not Found error. Even worse, if you’ve spent some time getting links to that old page, a 404 error is a sure way of discouraging people to link to you in the future.

Finally, a missing page is like telling Google that you’re closed for business and so send those users somewhere else. That’s not the message you want to send. Trust me.

In order to prevent this situation, you need something called a 301 redirect or a Permanent Redirect. It tells visitors (including the search engines) that this content is permanently moved to the new location. For search engines, a permanent redirect means a few different things, as follows:

  • They’ll show the new URL in the search listings instead of the old one.
  • They’ll eventually stop sending their crawler around to that old URL.
  • Most importantly, they’ll give credit for any links pointing the old URL to the new URL. so, all that hard work you did to build links carries over.

Win!

Not that these things may take some time – probably about two weeks for Google, and a little longer for MSN and Yahoo.

Installing and Configuring Path Redirect

Enter the Path Redirect module, stage right. The Path Redirect module is great for getting your site redirects working properly.

Carry out the following steps to install and configure Path Redirect:

1. Download the Path Redirect module from the link: http://www.drupal.org/project/path_redirect and install it just like a normal Drupal module.

2. Visit http://www.yourDrupalsite.com/admin/build/path-redirect/settings or click Admin | Site Building | URL Redirects | Settings.

3. Perform the following actions under the Settings option:

  • Display a warning message to users when they are redirected: Set to not ticked. This will avoid displaying a warning message like this:

  • Allow users to bypass redirects by adding ‘?redirect=no’ to the URL: Set to not ticked. Although, unlikely, if you have this setting turned on then you could create duplicate content if someone links to the ?redirect=no link. It’s great for testing but not worth the risk on production sites.
     
  • Discard redirects that have not been accessed for: Set to Never (do not discard). This will make sure that any old URLs are still redirected. If you run a huge site and are worried about database bloat, you could set this to 1 Year or even less. However, this is not an appreciable performance issue for most sites.
     
  • Default redirect status: Set to 301 Moved Permanently. This tells search engines that the content is gone and not coming back. There are other options but this is the best one most of the time.

4. Click on Save configuration.

How to Set Up a 301 Redirect

Now you’re ready for the main event! Carry out the following steps to set up a 301 redirect:

1. Make sure you have the Path Redirect module installed. It installs like any other Drupal module.

2. Set up the new alias for your content. Go to: http://www.yourDrupalsite.com/admin/build/path/add or from the admin screen click on Site Building | URL Aliases | Add Alias.

3. Under the Existing system path option, put the real location for the content. For example, node/128, forum/12, and so on.

4. Under the Path alias option, put the text you would like to use as the alias, like ties/paisley/calvin-klein do not add a slash before or after the text in this field.

5. Click on Create new alias. 6. Now, that you’ve created the alias, let’s redirect the old alias to the new one. Go to http://www.yourDrupalsite.com/admin/build/path-redirect/add or click on Administer | Site Building | URL Redirects | Add Redirects

  • Under the From option, enter the old path. For example, http://www.yourDrupalsite.com/ties-paisley/calvin-klein
     
  • Under the To option, enter the new path. For example, http://www.yourDrupalsite.com/ties/paisley/calvin-klein
     
  • Under the Redirect Type option, make sure 301 Moved Permanently is selected. The other kinds of redirects are very rarely used. In general, you always want to use a 301 unless you know what you're doing.

7. Click Create new redirect.

8. Test the new alias to make sure that it works the way you want it to. FAQs for 301 Redirects

Alternate way to create 301s

The Path Auto module will automatically create 301s for you when you rename the path in the node edit screen. Just make sure that you have Path Auto configured to Create a new alias. Redirect from old alias.

How long should I keep redirects? How long you keep redirects depends on a couple of things. For the search engines index, I would only keep them for a couple of months. However, if someone has bookmarked that page or put a link to it on their web site, maybe you should keep it longer.

I would keep them as long as there are still people using them. You can do this very easily by telling the Path Redirect module to automatically delete redirects after a certain period of disuse. I like sixteen weeks or a year. That means that one year after its last use, the redirect will be deleted.