3

I'm setting up a multi-lingual site and want to force the language segments:

domain.com/en/
domain.com/fr/

However if you go in the URL bar and remove the en/ or fr/ it loads up the English page without the language segment. How do I force this to load. Have tried a few .htaccess suggestions found via Google but nothing is working.

  • Just wondering if you ever got a solution for this one? If so I'd be interested to hear what it is. Thanks! Andrew – Andrew Macpherson Nov 14 '17 at 13:32
  • Not yet, and not sure what to do. – CreateSean Nov 14 '17 at 13:51
2

Make sure to remove Craft’s default rewrite rule (“Send would-be 404 requests to Craft”) from the .htaccess in your document root, so it’s only in the .htaccess files of your locales’ subfolders. You can now remove the index.php as well and requests to your homepage domain.com/ should now respond with a 404 HTTP error.

You have now removed all (duplicate) routes starting at root level.

Last step is to redirect visits to the homepage to en/ via the .htaccess in your document root.

RewriteEngine On
RewriteRule ^$ /en [R=301,L]
  • Perfect, thank you. – CreateSean Nov 14 '17 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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