0

Hi there could somedoby explain please why https://www. SUBdomain does not redirect to https://non-www.sudomain

I am running nginx and seems like set up all the redirects but the one above seem to be redirected wrongly by Wordpress, I have all A records set up 2 for http version of main domain with and without www and two for https records. My config redirects are below. WordPress Address (URL) and Site Address (URL) are set to https://maindomain not sure if this is the issue and how to resolve it

    #Main domain confing
server {

server_name domain.club;

    access_log /var/www/bclub/logs/access.log;
    error_log /var/www/bclub/logs/error.log;

    root /var/www/bclub/;
    index index.php index.html index.htm index.nginx-debian.html;

    listen [::]:443 ssl http2; # managed by Certbot
    listen 443 ssl http2; # managed by Certbot

    ssl_certificate /etc/letsencrypt/live/domain.club/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/domain.club/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


    add_header Strict-Transport-Security "max-age=31536000" always; # managed by Certbot


    ssl_trusted_certificate /etc/letsencrypt/live/domain.club/chain.pem; # managed by Certbot
    ssl_stapling on; # managed by Certbot
    ssl_stapling_verify on; # managed by Certbot

}

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


#SUB-domain confing

server {

    server_name cdn.domain.club www.cdn.domain.club;

    access_log /var/www/cdn.bclub/logs/access.log;
    error_log /var/www/cdn.bclub/logs/error.log;

    root /var/www/cdn.bclub;
    index index.php index.html index.htm index.nginx-debian.html;

     etag off;


    listen 443 ssl http2; # managed by Certbot
    listen [::]:443 ssl http2; # managed by Certbot

    ssl_certificate /etc/letsencrypt/live/domain.club/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/domain.club/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


    add_header Strict-Transport-Security "max-age=31536000" always; # managed by Certbot


    ssl_trusted_certificate /etc/letsencrypt/live/domain.club/chain.pem; # managed by Certbot
    ssl_stapling on; # managed by Certbot
    ssl_stapling_verify on; # managed by Certbot


}

server {
    listen       80;
    server_name  cdn.domain.club www.cdn.domain.club;
    return       301 https://cdn.domain.club$request_uri;
}

Many thanks

0

WordPress Address (URL) and Site Address (URL) are set to https://maindomain

I mean, there's your answer. WordPress uses the URL you set in Settings as the canonical URL.

0

I have found the solution add below code to subdomain config solved it!

#Redirect  WWW to non-www 
    if ($host = www.cdn.domain.club) {

      rewrite ^(.*) https://cdn.domain.club$request_uri? permanent;

    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.