3

I have installed and built a website using Craft CMS (with latest updates). I'm running this Craft installation on a Homestead virtual machine.

When I enabled localization and translated entries in a structure section, the url opens a 404 page.

In my setup I have two locales nb_no and en. Both locales are enabled for the section artists. Both locales are using the same url structure for entries: artists\{slug}.

My configuration for siteUrl is as follows:

'siteUrl' => array(
    'en' => 'http://page.craft.dev/en/',
    'nb_no' => 'http://page.craft.dev',
),

Debbuging the problem I see that there is an error in TemplatesController.php. In the function actionRender($template, array $variables = array()) the value of $template is en/artists/andre-bratten instead of artists/_entry as is the case for the main language entry.

Further exploration of logs shows me that Craft executes the following query which returns no result:

[09:30:32.080][trace][system.db.CDbCommand]
Querying SQL: SELECT `elements`.`id`, `elements`.`type`
FROM `craft_elements` `elements`
JOIN `craft_elements_i18n` `elements_i18n` ON elements_i18n.elementId = elements.id
WHERE (elements_i18n.uri = :uri) AND (elements_i18n.locale = :locale) AND (elements_i18n.enabled = 1) AND (elements.enabled = 1) AND (elements.archived = 0). Bound with :uri='en/artists/andre-bratten', :locale='nb_no'
in /home/vagrant/web/ekko/craft/app/services/ElementsService.php (151)
in /home/vagrant/web/ekko/craft/app/etc/web/UrlManager.php (281)
in /home/vagrant/web/ekko/craft/app/etc/web/UrlManager.php (140)

In my database elements_i18n table the entries both have uri = "artists/andre-bratten" and different locales.

As well there is a problem with wrong locale in the sql query (nb_no instead of en). I set CRAFT_LOCALE to en in the public\en\index.php file.

As I'm rereading this I think that there could be a problem with resolving the correct path (i.e. removing en/ from the front) when the locale is set incorrectly. Does anyone have any ideas why this is happening?


Update

I found out that when I access http:\\page.craft.dev\en\ I am loading public\en\index.php. However when I access http:\\page.craft.dev\en\artists\{slug} it loads public\index.php. So I assume there is a problem with Homestead and nginx?

pauliusef
  • 163
  • 7
  • I found out that when I access http:\\page.craft.dev\en\ I am loading public\en\index.php. However when I access http:\\page.craft.dev\en\artists\{slug} it loads public\index.php. So I assume there is a problem with Homestead and nginx? – pauliusef Oct 10 '15 at 10:51
  • 1
    Double check your public\en\index.php and public\en.htaccess files are set up according to Localization Guide – Step 5! – carlcs Oct 10 '15 at 10:52
  • Oh didn't notice you use nginx. Have a look at Brad's recommended config: http://craftcms.stackexchange.com/a/980/125 – carlcs Oct 10 '15 at 11:01
  • Thanks, the issue was the nginx configuration. I hacked it a bit and it started working. Now I will try out config recomended by Brad and choose what works best. – pauliusef Oct 10 '15 at 11:51

1 Answers1

3

The issue appeared to be the nginx config. I updated it according to an example from here (Locales sub directories on Nginx) and it started working.

pauliusef
  • 163
  • 7