Version 4 (modified by Dana, 9 years ago) (diff)


How do I redirect web users from one page to another?

There are times when you are building a new website, where the organization of the new site varies so much from the old one that you can't use the same URLS as the old site did.

It's a good thing, when possible, to use old URLs because so many people bookmark certain pages. When users with old bookmarks go to your new website, you do not want to give them an unfriendly message saying simply that the page was not found.

There are a couple things that you can do to help make users who loved your site before continue to love your site now.

Drupal Users

With Drupal, you can easily create what are called URL aliases. You must have the module called Path enabled to use URL aliases. The path module is part of Drupal core, so you will not need to install it, just enable it from your Administration -> Site Building -> Modules page.

Once enabled, navigate to Administration -> Site Building -> URL Aliases.

Click Add Alias and then enter the existing path followed by the old URL path.

In addition, Drupal also has options for when:

  1. people try going to a page that they thought was there and isn't or
  2. people try going to a page that is outside of the realm of their permissions level.

First create the page you want to redirect the users to. Then, navigate to the "Administration -> Site configuration section" of your site and click on the option that says "Error reporting". In the spaces provided give the path or node number of the pages you created.

Examples of both kinds of pages:

Options outside of Drupal

Whether or not you are using Drupal, you can always create an Apache redirect. A redirect tells your site that when a person clicks on a specific old link, to go to a certain page on your new site. Information and ways to configure redirects are VAST and VARIED. There are two basic ones that this wiki covers the very basics of: Redirect, and RedirectMatch.

First, you will place the code for your redirect in the 'Web configuration' section of your Members control panel. The code for a redirect goes after the end of the close of the directory tag (</Directory>).

A simple Redirect tells your site that, for a specific page, to go to another specific page. The basic redirect looks like this:

Redirect [path] URL

In this example, '[path]' refers to the part of the URL that comes after the 'root' of your site. So for example the path of '' is '/this/that/etc'. The path represents the address that you want to redirects users from. So if a user has bookmarked 'http://mysite/this/path' and you want them to go to '', the full redirect will look like this:

Redirect /this/path

If you wanted to take them to a completely different site, you could do that also:

Redirect /this/path

There are a lot of ways to do this and to use this function. If you want more, you can google it.

The other kind of Redirect involves a 'wildcard'. A wildcard is usually represented by an asterisk '*' and generally means 'anything'. It's like in poker when I play a wildcard, I can make that card be anything I want.

The reason that it becomes useful is that the standard website has the following structure:

If you wanted to redirect everypage that had a path that started with'/firstpart/' then you will need a wildcard to do that. It prevents you having to create a redirect for every single webpage on your old site.

The simplest RedirectMatch is written like this:

RedirectMatch 301 ^/firstpart/(.*)$

So in this case, it is telling the configuration that when a user wants to go to the page:, or, or, or

to send those users to:

This is, again, a very condensed tutorial that is designed to just tell you one way to do things, and not in a way that teaches you deeper principles of these functions. There are other ways to use them as well. Some sites that go into this in more detail include:

The option that we did not discuss here is to use an .htaccess file to redirect folks. This isn't recommended and the reasons why is in this ticket: