NGINX Redirect http to https and non-www to ww

前端 未结 4 1523
闹比i
闹比i 2020-11-29 23:43

I\'m setting up an nginx server with an SSL.

The domain with the ssl is www.mydomain.com

I want to redirect all requests from:

http://mydomain.com, h

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-30 00:38

    #If you like to redirect all "http" to "https" then add the following:
    server {
            listen 80;
    
            server_name yourdomain.com;
            server_name www.yourdomain.com;
    
     if ($scheme = "http")
            {
                    rewrite ^(.*)$ https://yourdomain.com$1 permanent;
            }
    }
    

提交回复
热议问题