Use the Rules module with a custom rule which looks like so (in Rules export format):
{ "rules_redirect_multiple_paths" : {
"LABEL" : "Disallow multiple paths",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "init" : [] },
"IF" : [
{ "text_matches" : {
"text" : [ "site:current-page:path" ],
"match" : "about-us\\d+",
"operation" : "regex"
}
}
],
"DO" : [
{ "drupal_message" : {
"message" : "Redirect to path about-us ...",
"type" : "error"
}
},
{ "redirect" : { "url" : "about-us" } }
]
}
}
Some details about how to use read this rule:
- Rules Event: use the "Drupal is initializing" event, to ensure that the rule gets triggered BEFORE the actual content (of a path to be redirected) is shown. If you'd use an event like "content is viewed", you'd be too late, the content "would" already be shown.
- Rules Condition: verify if the path to be redirected matches any of the paths you want to be redirected, such as
about-us01
or about-us02
( * ).
- Rules Actions:
- Show a message about the redirect, which is just for QA testing (feel free to remove that Rules Action after you saw it working).
- Perform the actual redirect to the desired page.
( * ) Note that the actual Regular Expression I used goes a bit further: it would also perform a similar redirect for paths such as about-us03
or about-us456
, though it would not trigger such redirect for (eg) about-us/789
. Here is an attempt to translate the various parts used in the regular expression about-us\\d+
:
about-us
: it must start with about-us
.
\
: escape character.
\d
: it must be followed by a digit (anything from 0
to 9
).
+
: it may be followed by 1 or more of the preceding token (so one or more extra digits).
PS: If you're struggling with regular expressions, then have a look at RegExr.