Drupal 7 Redirect Module

By shane
Fri, 2012-09-14 13:09
comments
Daily Dose of Drupal Episode #8

Share with Others

In this episode we look at the Redirect module and how it can be used to easily create 301 redirects on your Drupal website. This is important for many reasons, but SEO is probably the biggest.

In this episode you will learn:

  • How the Drupal 7 Redirect module can help manage your old URL paths when migrating your website to Drupal.
  • How the Drupal 7 Redirect module can help keep your website users off of page not found pages.
  • How the Drupal 7 Redirect module automatically creates and manages redirects for you.

Welcome to another episode of the Daily Dose of Drupal, this is Episode Number 8 and this is brought to you by codekarate.com. Today we are going to look at the Redirect module and this can be important for a variety of reasons but it can really help with a few that I’ll talk about right now.

The first is if you are creating a Drupal site and you might be migrating of a previous site whether it was just HTML or a Wordpress site or any other type of site you’re migrating to Drupal and you have a whole bunch of past that you need to change. You can always do this in an .htaccess file or something to that extent but using the Redirect module makes it very easy to make sure that any of your old paths in your site get redirected to correct paths on your new Drupal site, and this is really important for SEO reasons.

The other thing is if you end up changing the paths on your site and you want to make sure that if anyone else that had a link out there that pointed out to that old page that it will get redirected to the new page and this is also important if you have other people linking to pages on your site and you want to make sure that they’re not going to run into a situation where they got a page and not found.

So the first thing that we’re going to do is we have our test site here, I’m going to download the Redirect module. Okay so now that it’s downloaded and we’ll go ahead and enable it and if you’re in Drupal 6 it was called Path Redirect I believe but in Drupal 7 it was just Redirect module.

And so now that we have the module installed we will go to Configuration and you’ll see that there is now a URL or Redirect Setting and this allows you to add Redirects. So let’s go ahead and say we want to add a Redirect and let’s say on your old site you had a page called contact.php, so we’ll just say it’s just a basic page for your site and we now want to redirect that to just the front page, we can do something like that and now we always want to use the 301 for SEO reasons generally. So now if we didn’t have a contact page for instance; we wanted to make the contact.php page redirect to the front page now this will work.

So if we try to go up here and you try to go to contact.php you’ll get redirected to the front page. So that way if someone else had a link out there pointing to that page on your site, if they’ll click that link they’ll still end up on the front page of your site rather than getting a 404 page. So let’s go ahead and add some content’ I’m going to add a basic page; call this Test Page, I’ll leave everything else the same.
So this is just a test page and you can see if you go into Edit there’s a URL Redirect section and it says that there’s no Redirects here. Let’s go ahead and create a path alias for this called Test-Page and we’ll save that and now you’ll notice the URL up here is /test-page, we can then come back into the Edit and you’ll see that the URL Redirect, there still isn’t any but if we want to change this to Test Page 2 and we come back in here there’s now a redirect from this page to this new or to this test page content. So what this means is if I go to /test-page it’s going to redirect me to /test-page2. So what the Redirect module does is it keeps tracks of anytime you change the URL of a specific Node Page in this example and it makes sure that if for some reason there was a link out there pointing to that old URL it will automatically be redirected to the correct page.

There’s also a module which many of you may be familiar with called Pathauto which is another good path related module but I’m not going to talk about it now because I’m guessing most of you have probably heard of it or use it but if not you should definitely look at it as it will make … it’ll make it so you don’t have to specify a URL alias when you’re creating a page or any other piece of content.

So instead of having to manually come in here and set a URL alias you can set up certain patterns that will automatically be created for you automatically. So that’s all there really is to cover today, the Redirect module is just a simple module that can make your life easier and help your website for SEO reasons and just usability reasons so people aren’t finding 404 pages or Page Not Found and just makes your life easier.

Go ahead and follow me on Twitter @smthomas3 if you’re not already and subscribe to my codekarate.com newsletter. Until next time, thanks for watching.