Redirect Token

Categories

Component ID

2410947

Component name

Redirect Token

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

1993

Component created

Component changed

Component body

Use tokens in "To" paths in Redirect module.

See https://www.drupal.org/node/1331582

Configure Redirect as normal

Go to /admin/config/search/redirect and add or edit a redirect.

Example of path replacement

From: account/edit
To: user/[current-user:uid]/edit

Example of query replacement (FacetAPI)

From: users/same-role
To: searchapidefaultuserindex/?f[0]=roles:[current-user:roles:keys:first]

Note: use unescaped url's

Be sure you paste unescaped url's in the Redirect interface. If you don't the redirect will not work. Say the above query is replaced to (unescaped):
searchapidefaultuserindex/?f[0]=roles:2
in your browser it will look like (escaped):
searchapidefaultuserindex?f[0]=roles%3A2

Where %3A means colon :
and %20 (not in this example) means a space
and %3F (not in this example) means a questionmark ?
and %5B (not in this example) means a open bracket [
and %5D (not in this example) means a close bracket ]
http://www.w3schools.com/tags/ref_urlencode.asp
http://meyerweb.com/eric/tools/dencoder/

Note: anonymous users

All 'current-user' tokens are dismissed for anonymous users.

Security considerations

To create a redirect a user must have "Administer URL redirections" permission.
This module only replaces tokens in To-paths, the From-paths cannot have tokens.
For anonymous end-users tokens from the 'current-user' group are not processed, but all other tokens will be evaluated by token_replace().
So carefully choose what tokens you expose.