Skip to main content
edited tags
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
added drupal version tag ('8')
Link
Benjen
  • 21
  • 1
  • 2
Source Link
Benjen
  • 21
  • 1
  • 2

How to remove 'destination' query paramater from link URLs in Drupal 8

For some SEO related reasons, I want to remove the destination paramaters that are attached to the login and register link urls below nodes.

The Link-URLs look like this:

http://example.com/user/login?destination=node/55%23comment-form

But I want it that way:

http://example.com/user/login

For Drupal 7, someone has made it with:

function moon_url_outbound_alter(&$path, &$options, $original_path) {
 // here "moon" is my theme, use your own.
  switch ($path) {
  case 'user/login':
  unset( $options['query']['destination'] );
  break;
 }
}

Source: How to remove the Destination parameter from an URL in Drupal 7?

This source https://www.drupal.org/node/2238759 says, in Drupal 8 hook_url_outbound_alter has been replaced with OutboundPathProcessorInterface. But with the given example there, I don't understand how I could make it to unset the destination paramaters with my .theme file.

Can someone please help and tell how to unset the destination paramaters in Drupal 8 ?

Thanks in Advance!