As an alternative, you could also use the Rules module for this.
Here is the rule you'd need for it (in Rules export format, just use copy/past to import it in your own setup):
{ "rules_redirect_an_old_path_to_a_new_path" : {
"LABEL" : "Redirect an old path to a new path",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "init" : [] },
"IF" : [
{ "text_matches" : {
"text" : [ "site:current-page:url" ],
"match" : "the_old_path",
"operation" : "starts"
}
}
],
"DO" : [
{ "drupal_message" : { "message" : "Sorry, the old path (= /the_old_path) is no longer in use, you will be redirected automatically to its corresponding path (= /the_new_path)" } },
{ "redirect" : { "url" : "the_new_path" } }
]
}
}
A few more tweaks to make it fit your exact scenario:
- change all occurences of
the_old_path
to my-account
.
- change all occurences of
the_new_path
to user
.
Whenever such redirect actually happens, the user will also receive an informational message like so:
Sorry, the old path (= /my-account
) is no longer in use, you will be redirected automatically to its corresponding path (= /user
)
If you don't want such message to appear, then just delete the line containing drupal_message
in the exported rule above.
Note: No Pathauto involved using this approach, just Rules.