Answer the question
In order to leave comments, you need to log in
How to fix nginx config for modx+babel?
Hello, I can not correctly configure the config for correct operation.
Almost everything works, but when I go to the main site, for example site.com, it sends me to site.com/ru,
but it needs to stay on site.com.
There are only 3 languages on the site: English, French and Russian. The default is English and is displayed without the en prefix.
Here is my config:
server {
listen 80;
server_name site.com www.site.com;
root /var/www/site.com;
index index.php index.html index.htm;
client_max_body_size 30M;
error_log /var/log/nginx/site.error_log notice;
rewrite_log on;
location @modx-rewrite {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
# choose the language that appears first in the accept_language header
if ($http_accept_language ~* "(fr|ru)") {
set $lang $1;
}
location ~ ^/$ {
rewrite ^ $lang/ redirect;
}
location ~ ^/(fr|ru) {
# redirect favicon.ico and assets/* and core/* requests to site root
rewrite ^/(fr|ru)/(favicon.ico|assets.*|core.*)$ /$2 redirect;
# main Babel rewrite
rewrite ^/(fr|ru)/(.*)$ /?cultureKey=$1&q=$2 break;
# MODX rewrite
try_files $uri $uri/ @modx-rewrite;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_ignore_client_abort on;
fastcgi_param SERVER_NAME $http_host;
}
location / {
try_files $uri $uri/ @modx-rewrite;
}
location ~ /\.ht {
deny all;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question