Www not redirecting to non-www

Hi,

I created a PHP / MySQL site, like so many times before. However I noticed now that this site does not redirect from www to non-www. I’ve created quite a few EE sites before and all of them did this without any problem.

The config is also the same …

Anyone know why this can be ?

Lex

I edit ee’s default nginx vhost files after site creation to ensure everything works properly. Here’s an example of my vhost file for an SSL site that redirects www to non-www:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name www.domain.com;
    include /var/www/domain.com/conf/nginx/*.conf;
    return 301 https://domain.com$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name domain.com;
    
    access_log /var/log/nginx/domain.com.access.log rt_cache;
    error_log /var/log/nginx/domain.com.error.log;
    
    root /var/www/domain.com/htdocs;
        
    index index.php index.html index.htm;
    
    include common/wpfc-php7.conf;      
    include common/wpcommon-php7.conf;
    include common/locations-php7.conf;
    include /var/www/domain.com/conf/nginx/*.conf;
}

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

Works perfectly.