How to redirect anonymous users to login page using Rules module?
The way I solved it as follow:


Events: Drupal is initializing
Conditions:


User has role(s) - Parameter: User: [site:current-user], Roles: anonymous user
NOT Text comparison - Parameter: Text: [site:current-page:url], Matching text: user/login

Actions: Page redirect - Parameter: URL: user/login




Export rule as follow:

{ "rules_login" : {
    "LABEL" : "login",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "login" ],
    "REQUIRES" : [ "rules" ],
    "ON" : { "init" : [] },
    "IF" : [
      { "user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "1" : "1" } }
        }
      },
      { "NOT text_matches" : { "text" : [ "site:current-page:url" ], "match" : "user\/login" } }
    ],
    "DO" : [ { "redirect" : { "url" : "user\/login" } } ]
  }
}