Strange Bug on Multilanguage-Page for Titles

Hey Sonja,

so i tried your solution, but same problem here…

I tested it on the staging server: staging.my-personalshopper.de and as you can see, the same problem occurs…

Here you have my htaccess:

# Kirby .htaccess

# rewrite rules
<IfModule mod_rewrite.c>

# enable awesome urls. i.e.:
# http://yourdomain.com/about-us/team
RewriteEngine on

# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder.
# Otherwise links or the entire site will break.
#
# If your homepage is http://yourdomain.com/mysite
# Set the RewriteBase to:
#
RewriteBase /

# In some enviroments it's necessary to
# set the RewriteBase to:
#
RewriteBase /

# block text files in the content folder from being accessed directly
RewriteRule ^content/(.*)\.(txt|md|mdown)$ index.php [L]

# block all files in the site folder from being accessed directly
# except for requests to plugin assets files
#RewriteRule ^assets/plugins/([a-zA-Z0-9\.\-_%=]+)/(.*)$ site/plugins/$1/assets/$2 [L,N]
#RewriteCond $1 !^plugins/[a-zA-Z0-9\.\-_%=]+/assets/.*
RewriteRule ^site/(.*) index.php [L]

# block direct access to kirby and the panel sources
RewriteRule ^(kirby|panel\/app|panel\/tests)/(.*) index.php [L]

# make panel links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^panel/(.*) panel/index.php [L]

# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]

</IfModule>

# Additional recommended values
# Remove comments for those you want to use.
#
# AddDefaultCharset UTF-8
#
# php_flag short_open_tag on




Redirect 301 "/profil.html" "/de/meine-philosophie/ueber-mich"
Redirect 301 "/serviceleistungen.html" "/de/leistungen"
Redirect 301 "/personalshopping.html" "/de/leistungen/personal-shopping"
Redirect 301 "/imageberatung.html" "/de/leistungen/typberatung"
Redirect 301 "/specials.html" "/de/leistungen/kleidung-als-business-faktor"
Redirect 301 "/workshops.html" "/de/leistungen/workshops"
Redirect 301 "/trends.html" "/de/trends"
Redirect 301 "/reise.html" "/de/leistungen/shopping-wochenende-in-paris"
Redirect 301 "/jubilaeum.html" "/de/leistungen"
Redirect 301 "/presse-medien.html" "/de/meine-philosophie/presse"
Redirect 301 "/pressemitteilung.html" "/de/meine-philosophie/presse"
Redirect 301 "/partner.html" "/de/meine-philosophie/partner"
Redirect 301 "/gutschein.html" "/de/leistungen/geschenk-gutschein"
Redirect 301 "/kontakt.html" "/de/kontakt"
Redirect 301 "/impressum.html" "/de/impressum"
Redirect 301 "/ufilm3/ufilm.html" "/de/meine-philosophie/presse"
Redirect 301 "/pdf/interview-silke-gerloff.pdf" "/de/meine-philosophie/interviews"
Redirect 301 "/index-en.html" "/en"
Redirect 301 "/profil-en.html" "/en/my-philosophy/about-me"
Redirect 301 "/serviceleistungen-en.html" "/en/services"
Redirect 301 "/personalshopping-en.html" "/en/services/personalshopping"
Redirect 301 "/reise-en.html" "/en/services/shopping-in-paris"
Redirect 301 "/gutschein-en.html" "/en/services/gift-voucher"
Redirect 301 "/kontakt-en.html" "/en/contact"
#RedirectMatch 301 "/(.+)\.html$" "/"

Isn’t there an appropriate solution for this? I can’t imagine that this wasn’t a case so far since multilanguage sites with old URLs are being built all the time, am i right?

Would it be possible to achieve this via routes?

Greets Tobi

I think routes should be possible, just make sure to return the right language code in your route as explained in the docs for multi-language sites: https://getkirby.com/docs/developer-guide/advanced/routing#multi-language-setup

Tried this, still getting routed back to /de as default… What am i doing wrong?

c::set('routes', array(
  array(
    'pattern' => '/profil.html',
    'action'  => function() {
      return site()->visit('my-philosophy/about-me', 'en');
    }
  )
));

````
Thanks Tobi

Could you try with the UID/URI instead of the translated URL-Key? Why does your route start with a slash?

I tried it on staging now and not local. It seemed to work at first but since the Neuland WLAN at the german ICE is nothing more but a joke i have to test it, when i’m at my hotel room… I hope to get it done via this way… I’ll let you know in the evening…

If this doesn’t work, i’ll ask Bastian myself tomorrow at the beyond tellerrand Workshop… :slight_smile: Maybe he has a solution…

Thanks so far and have a nice sunday.

Now I had a minute to test this in a langkit, this seems to work:

// example redirect route
c::set('routes', array(
  array(
    'pattern' => 'profile.html',
    'action' => function () {
      site()->visit('projects/project-a', 'de');
      return go('projects/project-a', 301);
    }
  )
));

As you can see, the untranslated uri/uid is used (English is the default language).

Hi Sonja,

I’ve been testing your solution now. Route is working and not affecting the headlines or the menu. But although i’m routing to the en-version in my route, it leads to the german version (de is default). You know what i could do about that?

Here’s my code from the config-file:

c::set('routes', array(
  array(
    'pattern' => 'profil.html',
    'action' => function () {
      site()->visit('meine-philosophie/ueber-mich', 'en');
      return go('meine-philosophie/ueber-mich', 301);
    }
  )
));

Thanks for your patience.

I think I’m at my wits end, worked perfectly for me in a Langkit. Do you happen to use language detection in your config.php file?

O.K. now i see. Sometimes you have to think outside the box. Think about things you did some time ago: I installed the Kirby Bricks Plugin from jenstornell for using the contact form as a module with a controller… Deactivated it and it works… Somehow i think it is routing to things nobody expects, including me. I hope this will fix this problem.

Sorry for the – at this point – very misleading Headline of this topic :frowning: But with knowing this, i am going to start all over from here…

Thanks Sonja for your help. I really appreciate the kindness in this forum…

At least you have found the culprit :slightly_smiling_face: There’s always a certain risk with using plugins that try to change the way Kirby works too much. Maybe now you can go back to using .htaccess for your redirects, it is actually preferable to using routes because it kicks in before PHP is called.