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.

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

1 Answer 1

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]
1
  • Perfect, thank you.
    – CreateSean
    Nov 14, 2017 at 20:42

Your Answer

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

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