Так чуть лучше:
server {
listen 80;
server_name site.com www.site.com;
return 301 https://site.com$request_uri;
}
server {
listen 443 ssl http2;
server_name www.site.com;
return 301 https://site.com$request_uri;
}
server {
listen 443 ssl http2;
server_name site.com;
#...
}
On 21.07.2020 15:50, fox wrote:
> У меня так работает:
>
> server {
> listen 80;
> listen 443 ssl http2;
> server_name www.site.com;
> return 301 https://site.com$request_uri;
> }
>
> server {
> listen 80;
> server_name site.com;
> return 301 https://site.com$request_uri;
> }
>
> server {
> listen 443 ssl http2;
> server_name site.com;
> #...
> }
>
>
> On 21.07.2020 14:38, akoval wrote:
>> Сейчас у меня такие настройки:
>>
>> server {
>> listen 80;
>> server_name www.site.com site.com;
>>
>> location / {
>> return 301 https://site.com$request_uri;
>> }
>> }
>>
>> server {
>> listen 443 default ssl;
>> server_name www.site.com site.com;
>> if ($host ~* ^www\.(.+)$) {
>> rewrite ^ https://site.com$request_uri permanent;
>> }
>> rewrite ^/(.*)/$ /$1 permanent;
>> ...
>> }
>>
>> if ($host ~* ^www\.(.+)$) { - не срабатывает.
>>
>> пробовал еще перед server { listen 443 default ssl; ... }, но тоже не
>> срабатывает:
>>
>> server {
>> listen 443 ssl;
>> server_name www.site.com;
>> return 301 https://site.com$request_uri;
>> }
>>
>> Куда смотреть?
>>
>> Posted at Nginx Forum: https://forum.nginx.org/read.php?21,288770,288770#msg-288770
>>
>> _______________________________________________
>> nginx-ru mailing list
>> nginx-ru@nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx-ru
>>
>
> _______________________________________________
> nginx-ru mailing list
> nginx-ru@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-ru
>
_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru