0

I have pages in path try/* and I would like to redirect to node/20. I tried path auto but using * is not allowed, I have to specify one by one.

Is there any module or way to redirect try/* to node/20

2

3 Answers 3

1

Use drupal current_path() and drupal_match_path() api to check the path and redirect to your defined path.

So in your case,

if (drupal_match_path(current_path(), 'try/*')) {
  drupal_goto('node/20');
}
0

You could redirect from .htaccess directly.

RewriteRule ^try/(.*)    node/20   [R=301,L]

Place the rule from above in the .htaccess file, the next line after RewriteEngine on

-1

Implement the hook hook_boot in your custom module. This hook gets invoked for every page request. In the hook you may implement the code to match the pattern of the request URI by using preg_match or by implementing the logic suggested by @manikandan kannan . You can then redirect using the code

header('Location: '.$GLOBALS['base_url'].'/node/20');

Not the answer you're looking for? Browse other questions tagged or ask your own question.