Rules module user/register I keep getting spammed/attacked looking at reports/db. Anonymous users keep trying to go to /user/register (but I disabled registering). So being annoyed by anons still trying to going to that url, I decided to write a rule:

{ "rules_anon" : {
"LABEL" : "Anon",
"PLUGIN" : "reaction rule",
"WEIGHT" : "-10",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "node_view" : [] },
"IF" : [
  { "user_has_role" : {
      "account" : [ "site:current-user" ],
      "roles" : { "value" : { "1" : "1" } }
    }
  },
  { "text_matches" : { "text" : [ "site:current-page:url" ], "match" : "user\/register" } }
],
"DO" : [ { "redirect" : { "url" : "node\/39" } } ]}}


Context: Node 39 is Page Not Found

I tried it and it did not work, gives me do not have access message. So I tried the rule for a different url (/about) and it worked. I am guessing that url /user/register has a special case where Rules can not override it. 

My question is: is there a way to redirect anonymous users from /user/register ?
Whatever you want to happen via Rules module when some link is clicked, if you're using Rules Event 'Content is viewed', you'll probably be too late:


the content (or whatever the clicked link is about) is already being shown, so if the Rules Conditions are satisfied, the Rules Actions will be performed. That is what 'Content is viewed' is all about.
if you didn't want to content (or whatever the clicked link is about) to be visible at all, well sorry, but you're too late.


If however you did want something to happen BEFORE showing the content (or whatever the clicked link leads to), then you should use Rules Event 'Drupal is initializing'. Refer to 'How to specify a Rules event like &quot;Content is &#39;going to be&#39; viewed&quot;?' for way more details on this.

Attention: Rules Event 'Drupal is initializing' gets triggered on every (repeat: every) page load in a Drupal site. So for performance reasons, you really want to limit the number of active Rules that use this Rules Event to an absolute minimum, i.e. as your last resort (if anything else fails).