search

Home  >  Q&A  >  body text

nginx https does not have www jump www settings

nginx version

nginx version: nginx/1.10.2

It has been implemented that http://(www).airknow.com jumps to https://www.airknow.com, but https://airknow.com cannot be implemented to jump to https://www.airknow .com How to modify the configuration

The following is my configuration

server {
    listen 80;
    server_name airknow.com;
    return 301 http://www.airknow.com$request_uri;
}

server {
    listen 80;
    server_name www.airknow.com;
    return 301 https://www.airknow.com$request_uri;
}

server {
    listen  443;
    server_name  www.airknow.com;
    ssl on;
    #...
}    
为情所困为情所困2751 days ago662

reply all(3)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-16 17:10:48

    When writing a 443 port, I solved it like this. Two 80 ports can be merged into one server_name www.xxx.com xxx.com

    reply
    0
  • 高洛峰

    高洛峰2017-05-16 17:10:48

    I tried adding a new server between the second server and the third server above

    server {
        listen 443;
        server_name airknow.com
        return 301 https://www.airknow.com$request_uri;
    }    

    After restarting, the https://airknow.com website cannot be accessed.

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 17:10:48

    Same question as yours, found the answer

    server {
        listen 443;
        server_name airknow.com
        return 301 https://www.airknow.com$request_uri;
    }    
    
    server {
        listen  443  default_server ssl;
        server_name  www.airknow.com;
       
    }   
    

    Like the above, add default_server ssl after 443 of the third server. I don’t know if there will be any negative effects

    reply
    0
  • Cancelreply