<p>The issue appeared to be the nginx config. I updated it according to an example from here (<a href="https://craftcms.stackexchange.com/questions/780/locales-sub-directories-on-nginx">Locales sub directories on Nginx</a>) and it started working.</p>

CC BY-SA 3.0
2015-10-10T11:52:39.860Z
2015-10-10T11:52:39.860Z
2017-04-13T12:51:00.160Z
pauliusef
<p>I have installed and built a website using Craft CMS (with latest updates). I'm running this Craft installation on a Homestead virtual machine. </p>

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

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

<p>My configuration for <code>siteUrl</code> is as follows:</p>

<pre><code>'siteUrl' =&gt; array(
    'en' =&gt; 'http://page.craft.dev/en/',
    'nb_no' =&gt; 'http://page.craft.dev',
),
</code></pre>

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

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

<pre><code>[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)
</code></pre>

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

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

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

<hr>

<h2>Update</h2>

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

CC BY-SA 3.0
2015-10-10T10:51:09.047Z
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
CC BY-SA 3.0
2015-10-10T10:52:30.407Z
Double check your public\en\index.php and public\en\.htaccess files are set up according to [Localization Guide – Step 5](http://buildwithcraft.com/docs/localization-guide#step-5-set-up-the-files)!
carlcs
CC BY-SA 3.0
2015-10-10T11:01:31.077Z
Oh didn't notice you use nginx. Have a look at Brad's recommended config: http://craftcms.stackexchange.com/a/980/125
carlcs
CC BY-SA 3.0
2015-10-10T11:51:03.557Z
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
<localization><database><request>
Translated entry page can not be found (404)
# Translated entry page can not be found (404)

(Asked by: username_0 on 2015-10-10)

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?

**Tags:** localization, database, request
> **Comments:**
> **username_0**: 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?  
> **username_1**: Double check your public\en\index.php and public\en\.htaccess files are set up according to [Localization Guide – Step 5](http://buildwithcraft.com/docs/localization-guide#step-5-set-up-the-files)!  
> **username_1**: Oh didn't notice you use nginx. Have a look at Brad's recommended config: http://craftcms.stackexchange.com/a/980/125  
> **username_0**: 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.  

---

## 1 answers

### Answer by username_0 on 2015-10-10. Score: 3 | Accepted answer

The issue appeared to be the nginx config. I updated it according to an example from here ([Locales sub directories on Nginx](https://craftcms.stackexchange.com/questions/780/locales-sub-directories-on-nginx)) and it started working.


---

