Score:0

Url-aliases or redirect without language prefix

ec flag

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

unusedspoon avatar
aq flag
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
mullzk avatar
ec flag
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
unusedspoon avatar
aq flag
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)
mullzk avatar
ec flag
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
mx flag
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.
mullzk avatar
ec flag
My default language is German / de. But yes, all the languages are prefixed. Non-Prefixed paths are redirected to /de/[unprefixed], which is exactly my problem...
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.