Можно еще короче. В блоке сервера для 80 порта указать:
return 301 https://$host$request_uri; ср, 15 июл. 2020 г. в 11:14, Dmytro Lavryk <[email protected]>: > if ($ssl_protocol = "") { > rewrite ^ https://$host$request_uri > <https://sorp.ae$request_uri> permanent; > } > > > ---- Увімкнуто ср, 15 лип. 2020 10:40:46 +0300 *akoval > <[email protected] <[email protected]>>* написав ---- > > Приветствую всех! > Нужна помощь... > > Раньше был сайт http://site1.com на одном хостинге (apache). Теперь > перенесли его на другой хостинг с сертификатом https://site1.com (nginx). > Теперь мне нужно чтобы новый сайт грамотно редиректил http на https, > то-есть: > http://site1.com/page1 -> https://site1.com/art/page1 > http://site1.com/page2 -> https://site1.com/blog/page11 > ... > > Сейчас в nginx на https://site1.com у меня такие блоки: > > server { > listen 80; > server_name www.site1.com site1.com; > > rewrite http://site1.com/page1 https://site1.com/page1 permanent; > > if ($request_uri = /index.html) { > return 301 https://site1.com; > } > return 301 https://site1.com$request_uri; > } > > server { > listen 443 default ssl; > server_name site1.com; > rewrite ^/(.*)/$ /$1 permanent; > > root /.../public; > > ssl_certificate /...; > ssl_certificate_key /...; > ssl_session_timeout 5m; > } > > но rewrite http://site1.com/page1 https://site1.com/page1 permanent; не > срабатывает. > что не так делаю? > > Posted at Nginx Forum: > https://forum.nginx.org/read.php?21,288702,288702#msg-288702 > > _______________________________________________ > nginx-ru mailing list > [email protected] > http://mailman.nginx.org/mailman/listinfo/nginx-ru > > > > _______________________________________________ > nginx-ru mailing list > [email protected] > http://mailman.nginx.org/mailman/listinfo/nginx-ru
_______________________________________________ nginx-ru mailing list [email protected] http://mailman.nginx.org/mailman/listinfo/nginx-ru
