我不太熟悉nginx和重定向。这可能是一个愚蠢的问题,但我希望有人能帮助我一点。
问题:
系统有一个全局默认的区域设置“de”为domain.com/...但对于一个域,我需要它作为默认语言。可悲的是,它是不可能改变默认语言,在该CMS为特定的域/网站。
"我现在要做的是“
如果在url(domain.com/...)中没有给出区域设置,那么nginx应该重定向到domain/it/...
其他区域设置是/de和/en und,不应更改。
“最后我想做的是”domain.com/... -> domain.com/it/...
domain.com/de/... -> no redirect
domain.com/en/... -> no redirect
domain.com/en/... -> no redirect
nginx配置中的实际位置是:
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ /_Resources/ {
access_log off;
log_not_found off;
expires max;
if (!-f $request_filename) {
rewrite "/_Resources/Persistent/([a-z0-9]{40})/.+\.(.+)" /_Resources/Persistent/$1.$2 break;
rewrite "/_Resources/Persistent(?>/[a-z0-9]{5}){8}/([a-f0-9]{40})/.+\.(.+)" /_Resources/Persistent/$1.$2 break;
}
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include /usr/local/etc/nginx/fastcgi_params;
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.socket;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param FLOW_REWRITEURLS 1;
fastcgi_param FLOW_CONTEXT Production;
fastcgi_param FLOW_ROOTPATH /var/www/public_html/current/;
fastcgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
fastcgi_param X-Forwarded-Port $proxy_port;
fastcgi_param SERVER_NAME $http_host;
fastcgi_param SERVER_PORT 443;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_read_timeout 300;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
我希望这是可以理解的
1条答案
按热度按时间zed5wv101#
有很多方法可以实现这一点。一个简单的解决方案是为每种语言使用前缀位置。
例如,将现有的
location /
块替换为: