http重定向到https使用了nginx的重定向命令。那么應該如何寫重定向?之前老版本的nginx可能使用了以下類似的格式。
rewrite ^/(.*)$ http://domain.com/$1 permanent;
或者
rewrite ^ http://domain.com$request_uri? permanent;
現在nginx新版本已經換了種寫法,上面這些已經不再推薦。
下面是nginx http頁面重定向到https頁面最新支持的寫法:
server { listen 80; server_name my.domain.com; return 301 https://$server_name$request_uri;}server { listen 443 ssl; server_name my.domain.com; [....]}
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。
新聞熱點
疑難解答