2

I have a localized site, localization works fine for homepage (/en/), however the links to other page does not work (/en/rooms) where /chambres works fine for default language.

The English 'chambres' page is accessible with /en/?p=rooms

I would like the english page being accessible with /en/rooms

It's definitely an Nginx vhost config issue. The config listed in Locales sub directories on Nginx didn't solve my problem.

This is my english index.php:

// Tell Craft to serve the English content
define('CRAFT_LOCALE', 'en');

This is in my general config file:

'quartiergeneral.craft.dev' => array(
        'devMode' => true,
        'usePathInfo' => true,
        'omitScriptNameInUrls' => true,
        'environmentVariables' => array(
            'basePath' => '/home/vagrant/Code/quartiergeneral/craft/public/',
            'baseUrl'  => 'http://quartiergeneral.craft.dev:8000/',
        ),
        'siteUrl' => array(
            'fr' => 'http://quartiergeneral.craft.dev:8000/',
            'nl' => 'http://quartiergeneral.craft.dev:8000/nl/',
            'en' => 'http://quartiergeneral.craft.dev:8000/en/',
        ),
    ),

This is my nginx config vhost:

server {
    listen 80;
    server_name quartiergeneral.craft.dev;
    root /home/vagrant/Code/quartiergeneral/craft/public;

    index index.html index.htm index.php;

    charset utf-8;

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

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

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/quartiergeneral.craft.dev-error.log error;

    error_page 404 /index.php;

    sendfile off;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}
4
  • For those who can't see deleted answers, maunoxyd solved the problem by changing the section type from single, which was accidentally selected, to channel.
    – carlcs
    Commented Aug 17, 2014 at 21:05
  • maunoxyd, could you please add a new answer. Or, if you don't want this Q/A to exist, delete your question? Thanks.
    – carlcs
    Commented Aug 17, 2014 at 21:08
  • No the issue is still happening, as it is in the above question. Previously I didn't get the link to work in other language, which now works but not without parameters in url
    – maunoxyd
    Commented Aug 18, 2014 at 9:25
  • 1
    Sorry maunoxyd, I read your (deleted) answer as if you solved the problem. Maybe you can find a solution here: Locales sub directories on Nginx
    – carlcs
    Commented Aug 18, 2014 at 9:49

1 Answer 1

5

Ok, I got it working with:

nginx vhost config:

location /en/ {
    try_files $uri $uri/ @enrewrites;
}

location /nl/ {
    try_files $uri $uri/ @nlrewrites;
}

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

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

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

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

And in general craft config:

'omitScriptNameInUrls' => true,
1

Not the answer you're looking for? Browse other questions tagged or ask your own question.