Last updated 17 April 2015. Created on 22 August 2008.
Edited by pingwin4eg, rvanderh1, Francewhoa, fago. Log in to edit this page.

The first short tutorial will show, how rules module can be used, to configure a simple page redirection after a user has logged in.


  • This tutorial is for the Rules module. Not Trigger core module. Trigger module's tutorial can be found here.
  • As an alternative to the following tutorial, one can just import the ready rule from here.



  • Token contributed module if you want to use tokenized URL. Make sure that the Token sub-module Token actions is activated.


  1. Create a new rule

    First we have to start a new rule. For this go into the rules admin center, click on "Triggered rules" and on the tab "Add a new rule". Select the event "User has logged in", set the label "On login redirect to account page" and click "Submit".
    Now we have created a new rule, which is still empty. Every condition and action that we add to this rule, will be evaluated on the event "User has logged in".

  2. Create a condition

    To not break one-time logins and avoid redirecting from user profile form where a user needs to provide their new password we need to set a condition on our rule.
    Click "Add condition". Choose the "Text comparison" type of condition and fill in fields: set "Text" to "site:current-page:path"; "Matching text" to "user/reset" (this is the common start part of the path where users appear after clicking one-time login URL); "Comparison operation" to "starts with"; and check the "Negate" checkbox. Save this condition.

  3. Create the redirection action

    To do so, click on the "Add an action" link, under the section "System", select the action "Page redirect" and click on "Next" button. In case you have the token module installed, the "Page redirect" action allows you to use token replacements. This allows us to place the user's id in the redirect path.
    So call the action "Redirect to the users account page" and set the path user/[account:uid]. Then activate the checkbox "Force redirecting to the given path, even if a destination parameter is given" - which is necessary, because Drupal always sets a destination parameter to the current page, if a user logs in. So, that our redirection applies, we need to activate this. Check the option, and click the "Save" button.

    That's all. Just log out and log in again - you'll be redirected... :)

Looking for support? Visit the forums, or join #drupal-support in IRC.


pritish’s picture

FYI following this tutorial, you'll log in and get a page not found error if you don't install the token module. The url trailer might end "/user/[account%3Auid]" upon logging in without enabling that module.

tryitonce’s picture

I tried to use this tutorial to change the login redirection from the user account (default in my Drupal installation) to the front page.

This tutorial din't work for me at all. As with so many instructions here the people writing them never take the time to put the correct terms and links in to make life easy and to avoid confusion.

Anyway, may be this tutorial works and I am on the wrong "garden path". In any case this is what I did to get users on login to the front page.

1. ..../admin/settings/actions (Actions settings page)
Go to the bottom and open the drop down menu to the left of [create] and choose Redirect to URL press [create].
2. A new window opens - "Configure an advanced action"
Here you should read -
Redirect to URL
In the line below add the page link where your users should arrive at after logging in. In my case I choose <front>.
Press [Save] and now you should have a new line added to "Actions available to Drupal:"
system ....... Redirect to URL ..... configure .... delete
3. Next step - go to Triggers. You can click on it above in the explanation text or use ..../admin/build/trigger/node.
Now choose the user tab or .../admin/build/trigger/user.
Go down to Trigger: After a user has logged in.
From the drop down box choose "Redirect to URL" and press [Assign].

Done!!! [I hope ;-) ]

If you are redirecting to another page you might need to experiment with the link code along the lines of .../content/user-start-here-page.

Good luck

Good luck .....
... more recent results of trying Drupal just once are -

dropchew’s picture

This really works thanks!

I had no luck with rules redirecting to frontpage but the action and trigger combo really solve it.

snohio’s picture

I know that this is probably idiotic, but it took me too long to realize that I had to enable the Trigger Module. I thought I would drop a note here to save other people like me 20 minutes.

castawaybcn’s picture

idiotic but useful, this simple tip saved me a lot of headaches. Thanks!!

bonus’s picture

Thanks you.

Francewhoa’s picture

Thanks for your comment snohio. I have updated the tutorial by adding a 'Requirements' section.

Loving back your Drupal community result in multiple benefits for you  
niemag’s picture

Your comment saved my day today. Great thanks! :-)

BUT... I have two sub-sites - each of them I would like to redirect to its own front page after logging in. With one sub-site your procedure works smoothly, but the second sub-site is always redirected to /admin.

Moreover I cannot force neither of them to redirect to any other URL (e.g., or node/2, or ... ... ... ...). It seems that there is only one direction for each sub-site (somewhere written) and nothing can chage it.

Is there any problem with my configuration? I am quite new in Drupal world... Maybe any module I need to install or switch on.

I appreciate any help.

guysaban’s picture

For redirecting to the front page just follow the tutorial at the top of the page and leave the redirect field empty. Explanation, since the redirect is relative to the sites Base URL (domain) leaving the redirect field empty will redirect to the base url. Anything placed in the redirect field will just be appended to the base URL.

Francewhoa’s picture

Thanks tryitonce. I re-wrote the tutorial base on you comment.

Loving back your Drupal community result in multiple benefits for you  
jsulmar’s picture

Hi Onopoc,
The original tutorial worked for me using the Rules module. I suggest you place your re-write into documentation for the trigger module, NOT the rules module. I think a lot of people are confused that trigger and rules modules are alternative, distinct implementations.

Max_Headroom’s picture

Adding my support for this. This tutorial is in the wrong place. I came looking for a Rules solution, not the Trigger and action modules

Quentin Campbell

jsulmar’s picture

Note that the trigger and rules modules are separate, alternative solutions to the task of "triggering actions". It appears that you were unable to get the rules tutorial to work, so you developed your own similar procedure using the trigger module.

I'm also still on the learning curve on this, but I think the rules module claims to be a more versatile and powerful alternative to the trigger module. The documentation doesn't make it completely clear, but I think one should turn off the trigger module in order to use rules.

mikebann’s picture

This works but it doesn't use the Rules module it uses the triggers module. This tutorial is for a different module the rules module. This comment should be moved to the triggers module.

sorry for the redundancy here. I didn't see the above comment in the stacking order.

ozwebguru’s picture

You need to install latest development version for token replacements to work. Any version after 27-AUG-2008.
Also see FAQ here

clintcar’s picture

I know I'm a newb, but I have followed the main instructions and the one in the thread exactly and cannot get the redirect to actually work. Assuming there is no step missing in either walkthrough, has anyone else had a problem getting this to work? I'm so excited about learning and using rules, but hitting a roadblock right away, am I the only one?


I was able to setup an exact same rule on users logging out. So my problem seems to be specific to a rule when a user logs in. Leaves me even more confused onto why... but at least I'm getting rules to work. Anyone have an explanation for this?

hosais’s picture


I set an action (redirect URL[internal or external links) to the Trigger (After a user has logged in). When a user login, it always goes to the orginal page (the page when it is logout status).

I tried to set another action (display message) to the same trigger (after a user has logged in). It shows the message.

Can anyone tells me why this URL redirect does not work?

Note: I tried both action/trigger or rules module. The results are the same.



FiNeX’s picture

I've the same problem: the debug message is displayed, but it shows the destination token, not the token value, and it doesn't do the redirect.

kuzyakiev’s picture

same problem(

i.harneet’s picture

I was getting same problem but now got the solution. In newer version of rules there will be a option of "force destination or redirection" just check that option and redirection would work.

robives’s picture

I had the same problem until I set the destination value to 〈front〉

GlossyIbis’s picture

Totally agree with jsulmar. In a tutorial about Rules to give examples of how to do something with Triggers and Actions - NOT Rules! - is ridiculous and confusing! For the sake of future readers please remove the Trigger and Actions example and put a Rules example.


tryitonce’s picture

Well, while you have a point it might still be good to show how things can be done one way or another.

What would help is a page that explains the difference of Rules and Triggers & Actions to those searching for solutions.

Much in in Open Source environment is confusing as there is no "Big Brother" structure. On the other hand there is a type of organised chaos and it actually seems the be the quickest way to find a solution.

Just watch how ants are searching what they need to bring back for the community. They have a random non-systematical approach and research has shown that this is the quickest and most efficient way of searching. So, having Rules and Triggers & Actions mixed up will eventually lead to finding something more quickly and should help people to understand the difference as experts like you add their experience to the melting pot.

Thanks ....

Good luck .....
... more recent results of trying Drupal just once are -

Anonymous’s picture

Gonna have to agree here. Came to find a basic example to guide me into the realm of Rules because the other tutorials are a step ahead of me at the moment... and this tutorial doesn't even have to do with Rules.

Welp way to get my hopes up.

Francewhoa’s picture

Indeed this tutorial was listed under the wrong category. I moved it to Trigger module's book at

Direct link:

Any volunteer to write a tutorial for the rules module?

Loving back your Drupal community result in multiple benefits for you  
canishk’s picture

Try custom destination module.

andrewjsledge’s picture

Here is a key thing to know that may not be so obvious: when doing a preg_match you have to cast it as a bool. For example, I want to assign a role at login based on what the LDAP-authenticated user has as their DN. Just checking against the $account->data (which has to be unserialized as well) with preg_* won't work without the proper data type. This is what I had to do in the custom PHP code for the conditional:

$ldap = unserialize($account->data);
$pattern = "/.+dc\=student\,dc\=university\,dc\=edu/i";
$retval = (bool)preg_match($pattern, $ldap['ldap_dn'], $matches, PREG_OFFSET_CAPTURE);
return $retval;

If "dc=student,dc=university,dc=edu" is in the user's DN, the student role gets assigned to them.

Modules used:

chyatt’s picture


Doesn't ldapgroups handle the role assignment stuff for you? Are you using custom PHP code to work around a problem of some kind?

The reason I ask is I'm not getting a role assigned on first login via ldapgroups. On second login, the group is correctly assigned. So, for example, if I have studentA sign in via LDAP for the very first time (i.e. her account is just now created via ldapauth), she doesn't get assigned the *student* role prior to rules executing. But if I log out and log back in, she already has the student role, and a rule looking for that role works perfectly.


andrewjsledge’s picture

At the time, yes: we had other things (besides what you saw) going on that required us to get a definitive boolean response.

timtunbridge’s picture

This is going to sound so lame. Make sure the path you specify actually exists - I had created a page called volunteers but set the redirect to volunteer. Spot the difference, obvious once you know.

alexx90’s picture

How can I use this tutorial to redirect user after the registration to a page where there is a welcome text

pingwin4eg’s picture

Added a step with adding a condition to avoid breaking one-time logins.