1

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

1 Answer 1

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.

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.