How to change Wordpress site URL when migrating site to/from another server?

Multi tool use
How to change Wordpress site URL when migrating site to/from another server?
I have a Wordpress site that is currently running at www.example.com
, hosted on a shared hosting environment. I am moving it off of this shared server, onto a cloud VM platform where I will be running a web server to host the site.
www.example.com
So far, I have copied the wordpress
directory into /var/www/
on the new server, and configured Apache to point to /var/www/wordpress
. I also created a copy of the Wordpress database from the old server, and imported it into mysql
on the new server.
wordpress
/var/www/
/var/www/wordpress
mysql
Before transferring the DNS for www.example.com
to point to the new server, I want to make some changes to the copy of the site on the new server, using the IP address of the new server to access the new local copy, instead of the domain name www.example.com
(I want to keep the original site running on the old server in the meantime, so that there is no downtime).
www.example.com
www.example.com
But after copying everything over, I cannot access the site on the new server, because the site URL is still set to www.example.com
internally, so when I type in http://215.15.7.100
, I just get redirected instantly to www.example.com
(the existing live site on the shared server).
www.example.com
http://215.15.7.100
www.example.com
I have tried to follow the Wordpress instructions at Changing the Site URL, but they are incorrect or missing something. I did as suggested there and added the following to my wp-config.php
:
wp-config.php
define('WP_HOME','http://215.15.7.100');
define('WP_SITEURL','http://215.15.7.100');
... but this had no effect. It still automatically redirects me to example.com
.
example.com
I also tried updating the wp_options
table in the MySQL database, to change the siteurl
and home
settings. To do this, I ran the following queries:
wp_options
siteurl
home
update wp_options set option_value = 'http://215.15.7.100' WHERE option_name = 'home';
update wp_options set option_value = 'http://215.15.7.100' WHERE option_name = 'site_url';
... the fields were updated correctly in the database, but again, it has no effect and the site still redirects me instead of using this value.
The documentation mentions a variety of other suggested methods, with no discussion of when each is desirable to use. But at this point, I don't want to keep randomly trying things that don't work, because I don't want to mess things up.
How do I change the site URL so that it won't redirect me, and will instead just use the server IP as the base URL?
thanks you are correct - it was the browser cache. clearing the cache for the site fixed it. I feel silly now because I spent hours looking at docs on apache and wordpress trying to figure this out lol :) I didn't even realize that browsers cached redirects. anyways, thanks!
– J. Taylor
Jul 4 at 3:00
1 Answer
1
In this case OP needed to clear his own cache, so do a hard refresh or reset your browser first, then any caching plugin you may be using.
If you still are having issues with something like this, go through the following steps.
Go into phpmyadmin (make sure you are looking at the right database!), and double-check that the entries in wp_options (you might have other prefix), siteurl and home cells say what you want them to say. If no, you can edit them straight through the phpmyadmin gui, instead of using SQL commands.
Make sure your wp-config.php file on FTP/file server is hooked up to the correct database, with the correct user and password. Also check that the prefix matches the prefix of the database.
If you have access to the backend of Wordpress, refresh your permalinks, by switching forth and back to a new url structure, and back to your usual one.
As a last effort, try backing up all your plugins locally, and then deleting them from the WP install, in case you have some sort of redirect on top of the usual base-wordpress install.
The next steps are to check your theme or theme settings, or to start looking at DNS-redirects set up with your domain-host but that is a big and hairy world, and a bit outside the scope of your question.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
you have updated wp-otions too, then also its not working means, its cache, try in different browser or clear cache if your are using wp-engine hosting
– charan kumar
Jul 3 at 8:37