WordPress Multisite - 将主站点从无 www 更改为 www

WordPress Multisite - 将主站点从无 www 更改为 www

我已开始wildcard SSL-Certificates通过进行自动发行acme-dns-client。虽然有一种简单的方法可以同时覆盖我的所有子域,但我遇到的问题是,没有任何覆盖我的无 www 域。

因此,我认为这可能是一个好主意,而change the no-www Mainsite不是www.example.netexample.net


是否有人对如何更改这些设置有建议,因为它们在 Wordpress Multisite 管理仪表板中不可用,在这里您只能更改子页面的子域。


我已经尝试将以下行添加到中wp-config.php

define('WP_HOME','https://www.example.net');
define('WP_SITEURL','https://www.example.net');

但这还没有奏效。我使用 nginx 作为我的根 Web 服务器系统。


Nginx 配置

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

            location ~ \.php$ {
                         include snippets/fastcgi-php.conf;
                         fastcgi_pass unix:/run/php/php7.4-fpm.sock;
             fastcgi_connect_timeout 300s;
                 fastcgi_read_timeout 300s;
                 fastcgi_send_timeout 300s;
            }

            location ~ /\.ht {
                         deny all;
            }

            location = /favicon.ico {
                         log_not_found off;
                         access_log off;
            }

            location = /robots.txt {
                         allow all;
                         log_not_found off;
                         access_log off;
           }

            location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                         expires max;
                         log_not_found off;
           }

        root /var/www/wordpress;
        index index.php;

        server_name example.net www.example.net get.example.net *.example.net;

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.net/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.net/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

    #settings for file upload
    client_max_body_size 32M;
}

server {
    if ($host = example.net) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80;

        server_name example.net *.example.net;
    return 404; # managed by Certbot


}

相关内容