<p>Seems like I needed a bit more configurations for NGINX, something like</p>

<pre><code>location /es/ {
    try_files $uri $uri/ @esrewrites;
}

location @esrewrites {
    rewrite ^/es/(.*)$ /es/index.php?p=$1? last;
}
</code></pre>

<p>for each locale. 
Source: <a href="https://gist.github.com/cmalven/5cc95cce4e495d3a11df" rel="nofollow noreferrer">https://gist.github.com/cmalven/5cc95cce4e495d3a11df</a></p>

<p>Still not sure if there is a better option that avoids hard coding locales in NGINX config file.</p>

CC BY-SA 3.0
2017-07-26T13:09:47.827Z
2017-07-26T13:09:47.827Z
Alessio Breviglieri
<p>I'm stucked with a 404 error on all my localized sub-directories.
It works fine for the homepage ( es. <code>domain.com/e</code>s, <code>domain.com/it</code> ). Also urls in the main directory are behaving correctly. Example:
<code>domain.com/products</code> is fine <code>domain.com/es/products</code> is not.</p>

<p>I'm running Craft Pro on Nginx. Here is my <code>general.php</code>:</p>

<pre><code>'siteUrl' =&gt; array(
        'en' =&gt; 'http://129.0.1.67/',
        'en_us' =&gt; 'http://129.0.1.67/us/',
        'de' =&gt; 'http://129.0.1.67/de/',
        'fr' =&gt; 'http://129.0.1.67/fr/',
        'it' =&gt; 'http://129.0.1.67/it/',
        'es' =&gt; 'http://129.0.1.67/es/',
        'tr' =&gt; 'http://129.0.1.67/tr/',
        'ru' =&gt; 'http://129.0.1.67/ru/',
        'zh' =&gt; 'http://129.0.1.67/zh/'
)
</code></pre>

<p>Here is my index.php file for subfloders</p>

<pre><code>/**
 * Path to your craft/ folder
 */
$craftPath = '../../craft';

/**
 * Define Craft locales
 */
define('CRAFT_LOCALE', 'es');

/**
 * Define Craft Templates Path
 */
 $templatePath = '../../craft/templates';
define('CRAFT_TEMPLATES_PATH', $templatePath);
</code></pre>

<p>I'm assuming that my problem is with my NGINX configuration but I'm not confident with it.</p>

<pre><code>    root /var/www/app;


    location / {
            try_files $uri $uri/ @rewrites;
    }

    location @rewrites {
            rewrite ^(.*) /index.php?p=$1 last;
    }


    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
    }
</code></pre>

<p>Here is a Craft log in the browser console:</p>

<pre><code>[12:46:33.764][error][exception.Craft\HttpException.404]
Craft\HttpException in /var/www/craft/app/controllers/TemplatesController.php:72
Stack trace:
#0 [internal function]: Craft\TemplatesController-&gt;actionRender('es/oil-news/pro...', Array)
#1 /var/www/craft/app/framework/web/actions/CAction.php(109): ReflectionMethod-&gt;invokeArgs(Object(Craft\TemplatesController), Array)
#2 /var/www/craft/app/framework/web/actions/CInlineAction.php(47): CAction-&gt;runWithParamsInternal(Object(Craft\TemplatesController), Object(ReflectionMethod), Array)
#3 /var/www/craft/app/framework/web/CController.php(308): CInlineAction-&gt;runWithParams(Array)
#4 /var/www/craft/app/framework/web/CController.php(286): CController-&gt;runAction(Object(CInlineAction))
#5 /var/www/craft/app/framework/web/CController.php(265): CController-&gt;runActionWithFilters(Object(CInlineAction), Array)
#6 /var/www/craft/app/framework/web/CWebApplication.php(282): CController-&gt;run('render')
#7 /var/www/craft/app/framework/web/CWebApplication.php(141): CWebApplication-&gt;runController('templates/rende...')
#8 /var/www/craft/app/etc/web/WebApp.php(290): CWebApplication-&gt;processRequest()
#9 /var/www/craft/app/framework/base/CApplication.php(185): Craft\WebApp-&gt;processRequest()
#10 /var/www/craft/app/index.php(62): CApplication-&gt;run()
#11 /var/www/app/index.php(67): require_once('/var/www/craft/...')
#12 {main}
REQUEST_URI=/es/oil-news/prova
</code></pre>

<craft-pro>
404 on localized entries - Nginx
# 404 on localized entries - Nginx

(Asked by: username_0 on 2017-07-26)

I'm stucked with a 404 error on all my localized sub-directories.
It works fine for the homepage ( es. domain.com/es, domain.com/it ). Also urls in the main directory are behaving correctly. Example:
domain.com/products is fine domain.com/es/products is not.
I'm running Craft Pro on Nginx. Here is my general.php:
'siteUrl' => array(
        'en' => 'http://129.0.1.67/',
        'en_us' => 'http://129.0.1.67/us/',
        'de' => 'http://129.0.1.67/de/',
        'fr' => 'http://129.0.1.67/fr/',
        'it' => 'http://129.0.1.67/it/',
        'es' => 'http://129.0.1.67/es/',
        'tr' => 'http://129.0.1.67/tr/',
        'ru' => 'http://129.0.1.67/ru/',
        'zh' => 'http://129.0.1.67/zh/'
)

Here is my index.php file for subfloders
/**
 * Path to your craft/ folder
 */
$craftPath = '../../craft';

/**
 * Define Craft locales
 */
define('CRAFT_LOCALE', 'es');

/**
 * Define Craft Templates Path
 */
 $templatePath = '../../craft/templates';
define('CRAFT_TEMPLATES_PATH', $templatePath);

I'm assuming that my problem is with my NGINX configuration but I'm not confident with it.
    root /var/www/app;


    location / {
            try_files $uri $uri/ @rewrites;
    }

    location @rewrites {
            rewrite ^(.*) /index.php?p=$1 last;
    }


    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
    }

Here is a Craft log in the browser console:
[12:46:33.764][error][exception.Craft\HttpException.404]
Craft\HttpException in /var/www/craft/app/controllers/TemplatesController.php:72
Stack trace:
#0 [internal function]: Craft\TemplatesController->actionRender('es/oil-news/pro...', Array)
#1 /var/www/craft/app/framework/web/actions/CAction.php(109): ReflectionMethod->invokeArgs(Object(Craft\TemplatesController), Array)
#2 /var/www/craft/app/framework/web/actions/CInlineAction.php(47): CAction->runWithParamsInternal(Object(Craft\TemplatesController), Object(ReflectionMethod), Array)
#3 /var/www/craft/app/framework/web/CController.php(308): CInlineAction->runWithParams(Array)
#4 /var/www/craft/app/framework/web/CController.php(286): CController->runAction(Object(CInlineAction))
#5 /var/www/craft/app/framework/web/CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)
#6 /var/www/craft/app/framework/web/CWebApplication.php(282): CController->run('render')
#7 /var/www/craft/app/framework/web/CWebApplication.php(141): CWebApplication->runController('templates/rende...')
#8 /var/www/craft/app/etc/web/WebApp.php(290): CWebApplication->processRequest()
#9 /var/www/craft/app/framework/base/CApplication.php(185): Craft\WebApp->processRequest()
#10 /var/www/craft/app/index.php(62): CApplication->run()
#11 /var/www/app/index.php(67): require_once('/var/www/craft/...')
#12 {main}
REQUEST_URI=/es/oil-news/prova

**Tags:** craft-pro


---

## 1 answers

### Answer by username_0 on 2017-07-26. Score: 1

Seems like I needed a bit more configurations for NGINX, something like
location /es/ {
    try_files $uri $uri/ @esrewrites;
}

location @esrewrites {
    rewrite ^/es/(.*)$ /es/index.php?p=$1? last;
}

for each locale. 
Source: https://gist.github.com/cmalven/5cc95cce4e495d3a11df
Still not sure if there is a better option that avoids hard coding locales in NGINX config file.


---

