How to block / restrict a list of URLs using Rules? I'm currently blocking access to some admin menu pages using the Rules module as follows:

Events: Drupal is initializing

Conditions:


Data comparison > Data to compare:[site:current-page:url] then URL1 to block
Data comparison > Data to compare:[site:current-page:url] then URL2 to block
Data comparison > Data to compare:[site:current-page:url] then URL3 to block
...


Actions:


Show a message on the site
Page redirect to home


I want to supply a list of URLs in one field rather than multiple data comparison conditions, is this possible in Rules?
Assume the relative paths for your 3 URLs are like my/path1 (for ULR1),  my/path2 (for ULR2) and  my/path3 (for ULR3). And assume your homepage has a relative path MyHomePage. And assume this question is about D7.

With these assumptions, you could use a rule that answers your question which looks like so (in Rules export format):

{ "rules_limit_access_to_some_urls" : {
    "LABEL" : "Limit access to some URLs",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "init" : [] },
    "IF" : [
      { "data_is" : {
          "data" : [ "site:current-page:path" ],
          "op" : "IN",
          "value" : { "value" : [
              "my\/path1",
              "my\/path2",
              "my\/path3"
            ]
          }
        }
      }
    ],
    "DO" : [
      { "redirect" : { "url" : "MyHomePage" } },
      { "drupal_message" : {
          "message" : "Access to the content located at \u0022\u003Cstrong\u003E[site:current-page:path]\u003C\/strong\u003E\u0022 is not allowed.",
          "type" : "warning"
        }
      }
    ]
  }
}


Note site:current-page:path token in this rule, which is different from site:current-page:url.

To make the above rule work in similar situations, just adapt the paths by changing 'my/pathX' (with X=1, 2, 3) to whatever fits. And adapt the message to be shown.

Some more samples where you can see this technique at work:


How to use the Rules module to implement a custom redirect for an outdated URL?
How to hide the content of nodes/ completely, and still maintain use within Drupal 7?
What is the best way to restrict website&#39;s direct access through node urls?


Remark: Instead of using a data comparison in this Rules Condition, you may also want to try using a text comparison. That would allow you to use regular expressions. If your URLs have a common pattern for which you can write to single regular expression (such as URLx, with x=1, 2, 3, ..., 456, 457, ...), you would only need 1 such Rules Condition.