0

My site’s domain name was originally devsite.com, last week I changed it to productsite.com on my virtual server( managed by virtualmin). I have also changed the setting and updated the database. I believe I have changed all occurences of “devsite.com” in the database to “productsite.com”. I am not sure if there is cache somewhere but one week has passed and when I open productsite.com in my browser, it still goes to devsite.com and open the default server in this IP. But if I get into incognito mode or open it with another browser, this problem will be no more. Not a big deal cause it doesn’t affect my users but it is quite bothering for me cause every time I had to use incognito mode to access my own site, also there might also be some potential problems somewhere.

I am not sure if this is a wordpress problem or a virtualmin problem, so I will also post this question to virtualmin forum.

1 Answer 1

0

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.

2
  • Why not make a complete search-replace : wp search-replace --all-tables --precise 'old-ndd.com' 'new-ndd.com' ?
    – Benoti
    Commented Jun 14, 2021 at 9:32
  • The --all-tables will target all tables. A lot of people here are using hosting with multiple sites sharing the same database, I don't want them to accidentally replace strings in another project. By not specifying what tables to target, it targets those registered to the $wpdb object. The reason i skip the guid-column, is that there is no point in replacing anything there. And if you would do it by accident, things might break. The --precis will use PHP instead of MySQL to perform the replace. It will be slower, and for this operation I, using mysql has never failed me. Commented Jun 14, 2021 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.