0

When moving an existing multilanguage site (Jive CMS) to Drupal we need to redirect URLs like /docs/DOC-1763 to the German version of a node. They are a lot, so we need a migration for it.

We're using the Redirect module, but when setting the language to German it only works for /de/docs/DOC-1763, which is of course not what is needed.

How can we redirect old root URLs like /docs/DOC-1763 to the new German version of this content? The URL would be /de/something/different for the node whose ID is 5, for example.

1 Answer 1

0

So it turns out, this is kind of a long known gab in the redirect module.

For us it worked with patch #42 in the redirect module (using cweagans/composer-patches composer library) and then importing the redirects using migration. This is what worked for us (massive thx to this example):

id: custom_redirects
label: 'Import DE urls as redirects to the node'
source:
  plugin: url
  data_fetcher_plugin: file
  data_parser_plugin: json
  # ... and the mapping, I spare you the details
  constants:
    status_code: 301
    redirect_prefix: 'internal:/de/node/'

process:
  temp_nid:
    plugin: migration_lookup
    source: jiveid
    migration: custom_contents
  language:
    plugin: default_value
    default_value: und
  redirect_source:
    - plugin: substr
      source: url/de
      start: 1
  redirect_redirect:
    plugin: concat
    source:
      - constants/redirect_prefix
      - "@temp_nid"
  status_code: constants/status_code

destination:
  plugin: entity:redirect

migration_dependencies:
  required:
    - custom_contents

So with our example above this would end up with values:

process:
  language: 'und'
  redirect_source: 'docs/DOC-1763'
  redirect_redirect: 'internal:/de/node/5'
  status_code: 301

The migrate module (don't forget the patch) does then the rest and redirects correctly from /docs/DOC-1763 to /de/something/different.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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