更改域名导致我的浏览器出现一些奇怪的问题

时间:2021-06-12 作者:shenkwen

我的网站的域名原来是devsite。上周我把它改成了productsite。我的虚拟服务器上的com(由virtualmin管理)。我还更改了设置并更新了数据库。我相信我已经将数据库中出现的所有“devsite.com”更改为“productsite.com”。我不确定是否有缓存,但一周过去了,我什么时候打开productsite。com在我的浏览器中,它仍然会转到devsite。com并打开此IP中的默认服务器。但如果我进入隐姓埋名模式或用另一个浏览器打开它,这个问题将不再存在。这没什么大不了的,因为它不会影响我的用户,但这对我来说很麻烦,因为每次我不得不使用匿名模式访问我自己的网站,也可能在某些地方存在一些潜在的问题。

我不确定这是wordpress问题还是virtualmin问题,所以我也会将此问题发布到virtualmin论坛。

1 个回复
SO网友:Fabian Mossberg

There are a few things that could cause this. Most likely this is something that is cached somewhere, so start with clearing the cache properly.

Clear the cache in your browser

If you are using chrome, open the devtools, open the "Application" tab and click "Clear site data".

Chrome also caches http redirects etc, but if you keep your devtools open, it\'s going to read the actual response from the server. So, with devtools open, do a hard reload ++R.

Check the redirect rules on your server

Make sure that there are no rules in your web server configuration file that is causing this redirect.

  • If you are running Apache, look in the sites .htaccess.
  • If you are running nginx, check the sites config file.

Overwrite any config

See if the problem goes away if you overwrite any settings with hard-coded settings.

Add the following to your functions.php

define( \'WP_HOME\', \'https://productsite.com\' );
define( \'WP_SITEURL\', \'https://productsite.com\' );

If you have access to the terminal, you can use wp-cli to update the settings there. Also, just to be sure, run the serach-replace here as well:

wp search-replace \'devsite.com\' \'productsite.com\' --skip-columns=guid
wp option update home \'http://productsite.com\'
wp option update siteurl \'http://productsite.com\'

If you don\'t have access to the terminal, you can do this serach replace using a plugin called Better Search Replace.

More info

A good read is the article Moving Wordpress on WordPress.org.

If you want to try to find out what\'s going on, you can look in the devtools in the Network-tab. Check the option "Preserve log", and go to the url you get redirected from. Click the first response you got, and look at the headers. They will give you a hint on why you got redirected.

If you have access to a terminal, you can just do:

curl -I https://productsite.com

It would give you something like:

HTTP/1.1 301 Moved Permanently
Date: Sat, 12 Jun 2021 14:09:27 GMT
Content-Type: text/html
Content-Length: 162
Connection: keep-alive
Location: https://devsite.com/

If this one is redirecting you, you need to keep looking for the problem.