Redirection: you want to go where?

One of my students asked me this week about how to redirect users from "here" to "there." We were looking specifically at redirection on login, but here's my top five ways to get visitors where they need to be:

  1. Path redirect - http://drupal.org/project/path_redirect
  2. Login Destination - http://drupal.org/project/login_destination
  3. Redirect 403 to User Login - http://drupal.org/project/r4032login
  4. LoginToboggan - http://drupal.org/project/logintoboggan
  5. drupal_goto - http://api.drupal.org/api/function/drupal_goto

Do you have other favourites? I'd love to know what they are!

Comments

I believe that you can do it using the Rules module http://drupal.org/project/rules

Yes, you can do that with Rules. I just did that when I built my own version of Twitterfeed. It takes external feeds and pushes links to Twitter. The problem with most 301 redirects is, as soon as they're triggered nothing else can happen, like counting the click. I wanted to track the number of clicks, so I used another module that should be on your list, Emma Jane, and that's the Bouncer Module: http://drupal.org/project/bouncer.

prevented me from posting a good piece about using the .htaccess file to redirect. Especially to make sure google only indexes one url (ie. only with www or only without www)


function MYMODULE_user($op, &$edit, &$account, $category = NULL) {
if ($op == 'login') {
drupal_goto('my/path');
}
}

When you're dealing with other forms, $form_state['redirect'] is the way to go.

Global Redirect has been around since the 4.7 days and takes on the task of redirecting any source URL's to their destination (eg, if node/1 was aliased to blog/bake-a-cake and you accessed node/ (from an old URL or out laziness) then Drupal/Global Redirect would redirect you to blog/bake-a-cake. It also handles frontpage urls, "deslashing" (which to a search engine implied the page is one level deeper than it really is) and trimming /0 off the end of pages such as taxonomy/term pages (taxonomy/term/1 and taxonomy/term/1/0 are the same page. The 0 implies infinite depth with is the default if not specified).

There is also work right now on getting it to work with multilingual pages (eg what happens if node/1 is english but you access is with fr/node/1? Should you see an English node with French navigation? Should you be redirected to the French version of the node? Should you be redirected to the English node, but with English navigation (eg en/node/1)?)

I thought I'd mention my small module too: Custom (Form) Destination. Lets you define redirection based on form id.

We've been doing a lot of "Drupalizations" of pre-existing sites recently. Using Path Redirect to redirect requests for an old path to the equivalent page at its new path has been wonderful for avoiding calls from angry customers who are wondering why they get 404s when they click on search results for their site soon after the new one goes live (and before the search engine has indexed the pages at the new paths yet). Definitely recommend it for those doing migrations like this.

-- Garrett Albright

Hi Emma,

The easiest way I've found is to create an action that will redirect to a url. (Look under Site Configuration->Action).
Then assign this action to a trigger that occurs when a user logs in. (Site Building -> Triggers -> Users).

You may need to enable the Trigger module. (its part of the core).

No need for additional modules.. :)
Nick

i have also a problem of redirect user thx. watches

The easiest way I've found is to create an action that will redirect to a url. (Look under Site Configuration->Action).
Then assign this action to a trigger that occurs when a user logs in. (Site Building -> Triggers -> Users).

You may need to enable the Trigger module. (its part of the core).
ged practice test | Printable GED Practice Test | GED Social Studies Practice Test | GED Science Practice Test | GED Math Practice Tests

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h2> <img>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.