How to create a rule to perform a redirect if user is already logged in and visits the homepage? I have a Drupal 7 installation. In my homepage I have only two forms (login and register) so I need when someone leaves the site and the user is logged in, when he visits it again that he redirect to another page (similar to Facebook functionality).

Currently the user is redirected to user profile page.

I tried to use Rules and I put in Rules Event 'Drupal is initializing', in Rules Condition path to 'check=[site:url]' to be redirected but with no effect.

Any ideas?
Not sure if it will be your only problem to be fixed, but you seem to be using the wrong token in your condition path. Try again using either of these tokens:


[site:current-page:path].
[site:current-page:url].


Below is an example of a rule (in Rules Export format) which illustrates how to use either of these tokens:

{ "rules_redirect_logged_in_user" : {
    "LABEL" : "Redirect logged in user",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "init" : [] },
    "IF" : [
      { "NOT user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "1" : "1" } }
        }
      },
      { "OR" : [
          { "data_is" : { "data" : [ "site:current-page:path" ], "value" : "node\/123" } },
          { "text_matches" : { "text" : [ "site:current-page:url" ], "match" : "something" } }
        ]
      }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "Using the path [site:current-page:path] (or url [site:current-page:url]) makes no sense for authenticated users, which is why you are redirected ..." } },
      { "redirect" : { "url" : "somewhere_else" } }
    ]
  }
}


Some more details about the above Rule:


Rules Event: Drupal is initializing.
Rules Conditions:


the user should NOT be anonymous, AND
either (or both) of these conditions must be true:
the path is node/123 (assuming your homepage is a node with nid=8, adapt to fit your case, or omit this condition if the next condition is sufficient for your case).
the url contains the text something (adapt to fit your case, or omit this condition if the previous condition is sufficient for your case). Instead of using Comparison operation contains you could also use starts with,  ends with or even a regular expression.

Rules Actions:


Show an appropriate message (adapt to fit your needs, or just omit it if you don't want such message at all, I like it for debugging purposes ...).
Perform a redirect to somewhere_else (adapt to fit your needs).



If you have the Rules UI enabled, you should be able to import the above rule in your own site. Then adapt it to fits your needs and you should be good to go.

Easy, no?