为什么选择https://www.WP将子域重定向到https://MAINdomain

时间:2019-06-17 作者:mag8891

嗨,能解释一下为什么吗https://www. 子域未重定向到https://non-www.sudomain

我正在运行nginx,似乎设置了所有重定向,但上面的一个似乎被Wordpress错误地重定向了,我有所有A记录,2个用于有无www的主域http版本,2个用于https记录。我的配置重定向如下。WordPress地址(URL)和网站地址(URL)设置为https://maindomain 不确定这是否是问题以及如何解决

    #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;
}
非常感谢

2 个回复
SO网友:Jacob Peattie

WordPress地址(URL)和网站地址(URL)设置为https://maindomain

我是说,这就是你的答案。WordPress使用您在设置中设置的URL作为规范URL。

SO网友:mag8891

我找到了解决方案,将下面的代码添加到子域配置中解决了它!

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

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

    }

相关推荐

Search redirects to index

我打算使用标准的WordPress搜索,但当我尝试搜索时,我使用的是索引,而不是搜索结果。搜索url似乎正确:https://example.com/blog/?s=admissions搜索表单<form role=\"search\" method=\"get\" class=\"search-form\" action=\"https://example.com/blog/\"> <label for=\"search-form-5cb5f4940c0aa\">