Force www. and https in nginx.conf (SSL)

前端 未结 4 1138
梦谈多话
梦谈多话 2021-02-05 20:48

After purchasing a SSL certificate I have been trying to force all pages to secured https and to www.

https://www.exampl.com is working and secure but only if type it i

4条回答
  •  孤街浪徒
    2021-02-05 21:20

    If you have a sites-enabled directory, do not use the "http" top directive. Just create another file (with any name) in the site-enabled directory that has:

    server {
        listen      80;   #listen for all the HTTP requests
        server_name example.com www.example.com;
        return      301         https://www.example.com$request_uri;
    }
    

    and comment out the line

    listen 80; 
    

    where the server_name is the same in the other file that serves www.example.com

提交回复
热议问题