1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help/How to? Redirect all request to https://www using Nginx+Spdy

Discussion in 'Server Configuration and Hosting' started by RoldanLT, Dec 14, 2013.

  1. RoldanLT

    RoldanLT Well-Known Member

  2. digitalpoint

    digitalpoint Well-Known Member

    Code:
    if ($ssl_protocol = "") {
        rewrite ^/(.*) https://$http_host/$1 permanent;
    }
     
    RoldanLT likes this.
  3. RoldanLT

    RoldanLT Well-Known Member

    I mean how to redirect all request to www.
    Redirecting to https already works fine with this code:
    Code:
    server {
        server_name .domain.com;
        return 301 https://www.domain.com$request_uri;
    }
    
    server {
      listen 443 ssl spdy;
      server_name www.domain.com;
    The only thing that didn't work is this:
    From https://domain.com to https://www.domain.com =
     
  4. digitalpoint

    digitalpoint Well-Known Member

    Oops... misread what was/wasn't working...

    Code:
    if ($http_host = "digitalpoint.com") {
        rewrite ^       https://www.digitalpoint.com/?  permanent;
    }
     
    RoldanLT likes this.
  5. RoldanLT

    RoldanLT Well-Known Member

    Where should I insert this code (from the codes I'm using above) ?
     
  6. Floren

    Floren Well-Known Member

    What you have works, if it does not then look at the logs as there is something else breaking your redirection. Example: https://axivo.com
    You can further cleanup that config:
    Code:
    server {
        server_name domain.com *.domain.com;
        return 301 https://www.domain.com$request_uri;
    }
    server {
        listen server_ip:443 ssl spdy default_server;
        server_name www.domain.com;
        ...
    }
    That is bad... and deprecated. He has the proper solution above.
     
    Last edited: Dec 19, 2013
    BamaStangGuy and RoldanLT like this.

Share This Page