admin管理员组

文章数量:1425661

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

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 $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 $request_uri;
}

Many thanks

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

Share Improve this question edited Jun 17, 2019 at 12:47 mag8891 asked Jun 17, 2019 at 12:42 mag8891mag8891 12 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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.

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;

    }

本文标签: redirectWhy httpswww SUBdomain is redirected by WP to httpsMAINdomain