Join the community today
Register Now

Domains Proper way to force non WWW to WWW with Centminmod

Discussion in 'Domains, DNS, Email & SSL Certificates' started by quicksalad, Jul 1, 2015.

  1. quicksalad

    quicksalad Member

    159
    9
    18
    May 31, 2015
    Ratings:
    +13
    Local Time:
    10:41 AM
    I'd read threads here related to what I wanted to happen and unable to find the right settings, hopefully this will help not just me but for all future Centminmod who wanted to redirect non www to www.

    Here's where I came from none to www | Centmin Mod Community

    I get the same issue, I was also redirected to Nginx test page :(

    Here's my config:
    Code:
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    #server {
    #            listen   80;
    #            server_name mysite.com;
    #            return 301 $scheme://www.mysite.com$request_uri;
    #       }
    
    server {
      server_name mysite.com www.mysite.com;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    Any advise how to do it?
     
  2. quicksalad

    quicksalad Member

    159
    9
    18
    May 31, 2015
    Ratings:
    +13
    Local Time:
    10:41 AM
    here's what I did:

    Code:
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    server {
                listen   80;
                server_name mysite.com;
                return 301 $scheme://www.mysite.com$request_uri;
           }
    
    server {
       server_name www.mysite.com;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    Am I doing it right?
     
    • Like Like x 1
  3. eva2000

    eva2000 Administrator Staff Member

    31,022
    6,925
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,431
    Local Time:
    3:11 PM
    Nginx 1.13.x
    MariaDB 5.5
    yup that's correct :)
     
  4. quicksalad

    quicksalad Member

    159
    9
    18
    May 31, 2015
    Ratings:
    +13
    Local Time:
    10:41 AM
    @eva2000 does it affects site loading? due to redirect?
     
  5. eva2000

    eva2000 Administrator Staff Member

    31,022
    6,925
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,431
    Local Time:
    3:11 PM
    Nginx 1.13.x
    MariaDB 5.5
    nope :)
     
  6. quicksalad

    quicksalad Member

    159
    9
    18
    May 31, 2015
    Ratings:
    +13
    Local Time:
    10:41 AM
    I noticed minimize redirects drop to red on gtmetrix after I enable it? why is that?
     
  7. eva2000

    eva2000 Administrator Staff Member

    31,022
    6,925
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,431
    Local Time:
    3:11 PM
    Nginx 1.13.x
    MariaDB 5.5
    • Like Like x 1