我们正在更改公司网站,旧的 wordpress 网站位于旧服务器 centos/apache 上,ip 为 10.10.10.20,而新网站有不同的 ip 10.10.10.200。交易只是编辑 dns 条目,因为新网站应该有相同的域名。旧的 ip 已从 dns 中删除,url 为https://www.example.com。
新网站https://example.com运行完美,但https://www.example.com或者www.example.com 显示错误:无法访问此站点
/etc/httpd/conf.d/site.conf
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/example.crt
SSLCertificateKeyFile /etc/pki/tls/private/example.key
SSLCertificateChainFile /etc/pki/tls/certs/DigiCertCA.crt
DocumentRoot /var/www/html
ServerName example.com
ServerAlias www.example.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html
Redirect "/" "https://example.com/"
ErrorLog /etc/httpd/logs/error_log
CustomLog /etc/httpd/logs/access_log combined
</VirtualHost>
.htaccess 文件
# BEGIN WordPress
<IfModule mod_rewrite.c>
# BEGIN Redirects
RewriteEngine On
# 301 redirect www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# 301 redirect to https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# END Redirects
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
开发人员安装了重定向插件,DNS中有如下条目:example.com 10.10.10.200和别名www.example.com
$curl -Iwww.example.com返回:
HTTP/1.1 302 Found
Date: Thu, 24 Feb 2022 19:21:01 GMT
Server: Apache/2.4.37 (centos) OpenSSL/1.1.1k
Location: https://example.com/
Content-Type: text/html; charset=iso-8859-1
我只希望 www 页面重定向到https://example.com,是不是因为 google/crawler 记住了我们的旧 ip 地址,并总是尝试旧的 dns 条目?我应该等几天吗?已经超过 48 小时了。能以某种方式修复这个问题吗?
谢谢你!