Changes between Version 1 and Version 2 of faq/domain/redirect-web-users

Feb 4, 2009, 1:07:01 PM (12 years ago)
Ana Willem



  • faq/domain/redirect-web-users

    v1 v2  
    11= How do I redirect web users from one page to another? =
     3There 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.
     5It'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.
     7There are a couple things that you can do to help make users who loved your site before continue to love your site now.
     9The first (ONLY FOR DRUPAL USERS) is to create friendlier pages for when: 1) people try going to a page that they thought was there and isn't and 2) people try going to a page that is outside of the realm of their permissions level.
     11Once you create those pages, you can navigate to the 'Site configuration' section of your administrative pages and click on the option that says 'Error reporting ( In the spaces provided give the path or node number of the pages you created.
     13Examples of both kinds of pages:
     14Access Denied:
     15Page not found:
     17The second thing that you can do is to create what is called a 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.
     19First, 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>).
     21The first thing you want to do is put the following text there:
     24RewriteEngine On
     27This tells your configuration that you are about to give it some code for what should happen when people enter specific URL that may or may not exist on your new site. Now for what comes after this...Technically, this text is not necessary specifically for the kinds of redirects that I am showing here.  It doesn't hurt to have it especially in the case that you plan to use other Redirects that require it (RewriteCond or RewriteRule).
     29A simple Redirect tells your site that, for a specific page, to go to another specific page. The basic redirect looks like this:
     32Redirect [path] URL
     35In 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:
     38Redirect /this/path
     41If you wanted to take them to a completely different site, you could do that also:
     44Redirect /this/path
     47There are a lot of ways to do this and to use this function. If you want more, you can google it.
     49The 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.
     51The reason that it becomes useful is that the standard website has the following structure:
     60If 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.
     62The simplest RedirectMatch is written like this:
     65RedirectMatch 301 ^/firstpart/(.*)$
     68So in this case, it is telling the configuration that when a user wants to go to the page:
     71, or
     72, or
     73, or
     77to send those users to:
     83This 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:
     86 or,
     87 or,
     91The 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: