mercredi 11 avril 2018

Site not loading when redirecting www to non-www

First, I followed this tutorial to set up HTTPS and redirect HTTP connections to HTTPS:

https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04

Then, I decided I want to redirect www to non-www, so I followed this tutorial:

https://www.digitalocean.com/community/tutorials/how-to-redirect-www-to-non-www-with-nginx-on-ubuntu-14-04

However, now my site doesn't load at all, no matter what combination of http/https or www/non-www.

Here are my domain DNS settings:

https://i.imgur.com/QGclZkF.png

Here's my nginx default config:

# Expires map
map $sent_http_content_type $expires {
    default                    off;
    text/html                  epoch;
    text/css                   max;
    application/javascript     max;
    ~image/                    max;
}

# Redirect www to non-www
server {
    server_name www.domain.ca;
    return 301 $scheme://domain.ca$request_uri;
}

server {
    # listen 80;
    # listen [::]:80;

    # SSL configuration
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server;

    expires $expires;

    root /var/www/html/public;

    index index.php index.html index.htm index.nginx-debian.html;

    server_name domain.ca;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

What am I doing wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire