I have old links, for example the following ones.

  • index.php/event/nr1
  • index.php/event/nr2

If users are coming on index.php/event/*, they should be redirected to /event.

How can I achieve this?

up vote 4 down vote accepted

You can use Match Redirect module.
How to use:
1) Enable module as usual
2) Go to configuration page /admin/config/search/match_redirect
3) Add redirect settings there
enter image description here

Check if(!empty(arg(1))) { drupal_goto('events')}

You can write this in any of your custom module using hook modulename_init() function.

In your case the argument number may change, please do check and change the argument number.

There are Rewrite Rules that can be used to achieve the same thing on drupal 7 as well as on drupal 8. Use this Rewrite Rule in .htaccess file located in Drupal Root directory.

RewriteEngine on
RewriteCond %{REQUEST_URI} index.php/event/
RewriteRule ^(.*) http://www.domain.com/event [L,R=301]

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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