0

How can I use url-aliases in additional languages without the language prefix?

From his old homebrew-CMS, my client has the following URLs:

  • example.com/english-page => redirecting to example.com/en/node/1
  • example.com/deutsche-seite => redirecting to example.com/de/node/1

I use Drupal 9.5.9, Redirect 8.x-1.8 and Pathauto 8.x-1.11. Default Language is German (de)

node 1 in German has url-alias '/deutsche-seite'
node 1 in its English Translation has url-alias '/english-page'

Opening the Site with the following URLs leads to different Results:

  • example.com/en/english-page => OK, opens in english
  • example.com/de/deutsche-seite => OK, opens in german
  • example.com/deutsche-seite => OK. Redirects to /de/deutsche-seite which opens in german.
  • example.com/english-page => Not OK, throws a 404.

How can I achieve that example.com/english-page redirects to example.com/en/english-page or renders the english translation of node 1? I did not find any settings on pathauto or languages, and if I try to create an Redirect manually, the redirect-module does not allow me to enter a path without language prefix (https://www.drupal.org/project/redirect/issues/3208013)

Thanks a lot for any hint... Kind regards, mullzk

6
  • When you say it won't let you add the DE specific redirect for /english-page. Do you mean its showing an error? Or just that its showing "/de" in the domain when entering the URL? As newer versions of redirect don't show the language selector and what you're trying should work fine Commented Jun 22, 2023 at 13:42
  • I am not sure I understand... I think I have the newest version of redirect (8.x-1.8) and there still is a language selector. The field 'Path' is prefixed with a language code (the one of current language or whatever set by the language selector. But my problem is in the 'To'-Field, where I should be able to point to the english-page, but it takes only the Node and automatically switches the language, and does not use /en/ if the url /english-page is called
    – mullzk
    Commented Jun 22, 2023 at 14:55
  • In the language field you'd need to select DE, in the "from" field enter "english-page", in the "to" select node 1 (using the autocomplete which will be in german) Commented Jun 22, 2023 at 14:58
  • this does prevent a 404, but does not solve the problem. When calling example.com/english-page, it gets redirected to example.com/de/deutsche-seite. instead, it should be redirected to example.com/en/english-page
    – mullzk
    Commented Jun 23, 2023 at 7:00
  • Did you check your Language settings? Does your English language settings have the "en" as the prefix? Usually the English as a default language is the only one that has en empty prefix.
    – prkos
    Commented Jun 27, 2023 at 21:48

1 Answer 1

0

Two ways to solve problem 1sy is patch for 9.x, 10.x branch. Dont working for me, but you can try link: https://www.drupal.org/project/drupal/issues/2689459

Second is lang neutral aliases module. It works for me ok https://www.drupal.org/project/language_neutral_aliases

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.