4

So I'm setting up a multi-lingual site for the first time, and I'm having some problems with the urls.

I followed the guide, step by step. I've set up the siteUrl in general.php:

'DEV' => array(
    'devMode' => true,
    'siteUrl' => array(
        'no' => 'http://teknologi.dev/no/',
        'en' => 'http://teknologi.dev/en/',
        'es' => 'http://teknologi.dev/es/'
    ),
),

And I guess that works, since I get a message in General settings that the siteUrl has been defined elsewhere.

General settings

Then I have a section called "Videos", which I've set up like this:

Videos section

And when I list out all the entries, the URL to one entry looks right, but I'm getting a 404. If I however change the Entry URL Format to include the locale letters, ex: no/videoer/{slug}, it works. But that makes the URLs write out the locales twice, so a URL might look like: http://teknologi.dev/no/no/videoer/orkanger, which of course gives a 404.

So is there some step I've missed?

Edit: I also have this structure in my www folder:

- .htaccess
- index.php // I needed this one for admin to work?
- no/
  - .htaccess
  - index.php
- en/
  - .htaccess
  - index.php
- es/
  - .htaccess
  - index.php

And in each of the localized index files I have changed the craftPath and the CRAFT_LOCALE

$craftPath = '../../craft';
define('CRAFT_LOCALE', 'no');

While the root index.php points craftPath to ../craft.

Edit 2: I tried deleting the root index.php, and while /no/ still worked, every subpage (ex: /no/videoer/) gave this error message:

The requested URL /index.php was not found on this server.

Do I need to do anything in my .htaccess for locales?

  • First time I did this I forgot to define CRAFT_LOCALE in each of the locales index.php, and I think that resulted in 404s all around. – megatrond Jul 14 '15 at 7:59
  • @megatrond Yeah, I did that too. But now that you mentioned it, I'm a bit unsure about my root folder setup. I've updated my question with file structure. – peirix Jul 14 '15 at 8:12
  • Don't think you need the index.php in your root. You would then access the CP from /no/admin/login. You could set up your htaccess so that /no/ is the default index page. – Patrick Nesbitt Jul 14 '15 at 8:18
  • @PatrickNesbitt Tried deleting the index.php file as you said, but that gave a whole new error that I've not seen before. I updated the question. – peirix Jul 14 '15 at 8:21
  • 1
    @perlix You shouldn't need anything in the htaccess file at root (except maybe a redirect to /no/)...your htaccess in each locale directory should be the standard Craft htaccess file. – Patrick Nesbitt Jul 14 '15 at 8:27
6

Okay, so I found the answer. And the reason it wasn't working is because I've been using another .htaccess (a hybrid of h5bp and Craft) than the default that comes with the Craft download. And this .htaccess included a RewriteBase, which was set to /. So when one tried to access /no/{slug} the RewriteBase would send it up one folder, basically. So I had to go into each of the locales .htaccess and set their RewriteBase to /no and so on.

I'm just gonna leave it here, and I'm pretty sure I'm gonna find this post again the next time I'm making a multi-lingual site and don't understand why all of my links are broken...

  • Thank you! My whole site wasn't showing my secondary locale except the homepage, and it was the hidden file .htaccess that didn't copy over onto the FTP. thanks for the save! – mateostabio Nov 3 '17 at 17:22

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.