server {
listen 80;
server_name www.domain.com domain.com;
return 301 https://domain.com$request_uri ;
}
server {
listen 80;
server_name www.domain.ru domain.ru;
return 301 https://domain.ru$request_uri ;
}
server {
listen 443 ssl;
server_name www.domain.ru;
return 301 https://domain.ru$request_uri ;
}
server {
listen 443 ssl;
server_name www.domain.com;
return 301 https://domain.com$request_uri ;
}
server {
listen 443 ssl;
server_name domain.ru domain.com;
# основная секция
}
AddDefaultCharset UTF-8
RewriteEngine On
RewriteCond %{HTTP:HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
https://example.com