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

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.
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.
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).
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).
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:
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.
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:
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?

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.

Related

Final steps for moving Wordpress site to another server

Ive read many other threads here and also guides as this is my first time moving a Wordpress site to another server and I think Ive done everything correct so far but not sure.
So far Ive done the following:
Backed up WP files and moved them to public_html of new server and ip
Created a new Mysql db along with user and imported the old DB
Checked the imported DB in phpmyadmin and everything seems to be
there Changed wp-config file to the new db details
Also defined the site url in wp-config like so:
define( 'WP_SITEURL', 'http://www.example.com' );
Finally Ive changed my local hosts file to the following:
new.ip.here example.com
when I visit example.com it seems to redirect to www.example.com which I believe should be my site as it is still on the old/current server.
I logged in to WP anyway and did a test post but the post then appeared on the site on the old server which I guess confirms what I said above?
When I run the following ping commands I get these results though
ping example.com - new ip returned
ping www.example.com - old ip returned
Have I done everything correct so far and if so how can I test the site on the new server if its redirecting me away?
thanks
Something I do each time to be sure that I didn't forget anything is to search for my old domain name in all the base and change to the new one. Because sometimes there are hard links in posts or pages...
If you made your own theme, verify there too... Sometimes people make this mistake to put hard links...
For your host files, this will work only for YOUR computer. Check if the DNS are correct instead. then the changes ill apply to everyone.
I had created the new mysql db and user in ssh and not cpanel, even though Id checked the permissions and everything seemed in order when I logged into mysql admin in cpanel for this ip it showed no dbs and users at all for that account, strangely though the db I had imported was there in phpmyadmin.
I created a brand new db & user in mysql admin and then used both the domain plus with 'www' in my hosts file and it looks like I can see the site on my new server now and done a test post which only appears there so I think this has fixed it.

wordpress move to localhost missing css

I'm trying to move a wordpress/buddypress web site to my local pc.
I created a virtual host with the exact same host name, copy the code and DB.
It works but every time I change the C:\Windows\System32\drivers\etc\hosts file to see the live original site, chrome miss-behave and get stuck.
So I tried to change the site domain on my local pc - I search&replace the code & db export from the site domain to my local domain (e.g. mydomain.com -> mydomainlocal.com), and I reinstall the DB.
The site is running but it seems to be missing some stuff - specifically design stuff, e.g. css is different, and logo display the site name instead of the logo.
It seems like the new domain name triggers a different configuration of the site, or a different theme.
Can someone please explain how to properly move a wordpress site localy with a local domain name?
I read some posts about this issue and it seems I was doing it right, I actually don't understand why the site looks different if I changed all reference both in the code and DB.
I'd suggest the problem lies with the fact you've performed a search and replace on the database.
WordPress serializes some data and by running a search and replace on it you'll have changed the lengths therefore breaking the serialization. Often things like theme options are stored in that way and will appear to reset when broken.
In order to update the URL you'll need a more advanced tool like: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Further information: https://codex.wordpress.org/Moving_WordPress#Changing_Your_Domain_Name_and_URLs
First You must change domain name in database wp-options table
where option_name is suteurl and home
If not help, see in wordpress admin panel theme settings, some
themes have setting and in setting those can have url setting
In browser , in source you can find errors, and in errors you can see
not correct urls
I was able to solve it answer thanks to Nathan Dawson answer, here are the actual steps I did.
I switch back to the original DB (in wp-config.php),
setup the local host of the original domain mydomain.com (NOTE that I didn't delete the settings of the new local host - mydomainlocal.com)
In mydomain.com/wp-admin/options-general.php I changed the WordPress Address (URL) and Site Address (URL) to the new domain mydomainlocal.com
click save
After saving this settings the site redirects to the new domain immediately, but since I kept the setting of the new domain it worked, and the problem is solved.
EDIT - a quick and simple solution is simply change "siteurl" and "home" in the database table "wp_options" (through phpMyAdmin or similar)

What step have i missed? Transferring wordpress site

So i have recently tried to transfer my wordpress site to another server.
I have followed a few guides, but i definately seem to be missing a step.
Basically what i have done is:
export original database (phpMyAdmin)
Save all relevant files (ftp)
install fresh wordpress on new server. (wp backend)
'drop' all table fields in new wordpress (phpMyAdmin)
import original database to new location (phpMyAdmin)
transfer theme, plugins, uploads. (ftp)
activate theme, plugins. (wp backend)
update permalinks. (wp backend)
The problem is, i am left with a default looking wordpress installation, and not my orginal page-home.php and corresponding css.
Also, if i go to wordpress backend SETTINGS > READING > Frontpage:static; i only have the option of 'about', not home, i should have 'home'...
Sorry if i am vague, let me know if any screenshots are required.
We really need a little more info like:
when you say plain, do you mean just the theme is not set and you're on the default theme, or there is no theme, or do you mean even your content is not there?
the site you removed it from, where was the installation located? Was is in the public_html folder or a subfolder of that? Did you put it in the same place, ie not inadvertently put it in a different folder
(I've actually typed the bulk of the post and come back to the top for this one, but):
Are you sure you're checking the right site?
Have you kept the same domain name?
Has the domain name propagated to the new server?
Is the CSS being loaded from the correct domain (has anything been hardcoded to the old server)
Let's go through a few broader options:
1. Check how many WordPress installs are on your domain
First off, it sounds like you may have two WordPress installations. If you have the backend setup correctly with your themes but you're seeing a plain site, it sounds like you're looking at another install. I'm not saying you do have multiple installs, but it is a place to start looking.
A question to ask yourself here is: In this plain looking site, do you see your content, or the content of a default site? If you see your content, you may jump ahead to section 2.
If you're saying there is a home page but you're not seeing it as available under static pages, either:
You're looking at another site (but there should be a home page* even in a default setup—from memory), or
You're Home Page title may have changed, or have become "unpublished", ie reverted to a draft, or pending review. Check the page:
actually exists,
has the title you're looking for
the slug hasn't changed
(*note: although it could be a Welcome Page I'm thinking of here.)
Double check the database
The easiest way to do this is to go into your database and see how many WP databases there are. Check each database and look for the underlying table structure, it sounds like you should be able to identify it pretty easily. If it's not a multisite install, the table prefixes should be wp_ unless you changed them somewhere.
While you're playing around in the database, Take note of the database name and table prefix.
Double check the folder structure
Have a look for a second instance of your folder structure, maybe you dropped it into the wrong place).
2. Check the WordPress installation is actually connected to the database
Check the WordPress configuration file wp-config.php is connected to the database. Check wp-config.php sample from codex, you'll want to see the correct database name and table prefix in there.
From here you should also check the username has been setup correctly and is as you expect it. Remember, the database name will likely have a different prefix between hosting providers, unless you've managed to keep the same login name with each provider. ie, I'm talking about the database prefix here, not the table prefix.
(another note: most database connection issues will result in errors appearing on the page in lieu of your site, which leads me to believe it's at least partially setup correctly.)
TEST: What you can do is rename the old wp-config.php to something else and don't create a new one, then visit the website and it will lead you into setting it up again where you can enter the database details (your site info will still be intact, this will only reset your config file, not the database, although it could reset the connection between the filesystem and database).
3. Domain name propagation and DNS settings with your new host
As I mentioned previously, are you checking the right server? Are you sure the domain name has been propagated (if you're using the same domain name that is).
Check the IP address with your DNS provider (for your domain name) is correctly pointed to your new server
Then check that from your command line by typing ping {your-domain-name} and see that your IP address comes up
Check the DNS settings with your web host are setup correctly and that your domain name points to where you want it to point to (ie, public_html or the relevant subdirectory there-of). (This resally does come back to point one, which if you covered it, this shouldn't be an issue
Check that you dropped the files (and all the files) into the correct physical directory, ie public_html (or sub-dir)
If none of these help, please leave a comment with any further developments you've made and as much info as possible, and we can start looking in other areas.
*notes about the database name:
when playing with WordPress directly, ie in the configuration files or the backend administration settings, the database will include your {username}[underscore or hyphen]{database-name}
when playing in phpMyAdmin, they will already be included and you will just provide the {database-name}.
Fellow this steps
export your sql from cpanel---phpmyadmin
make zip of your files in cpanel
import the file in new domain and extract it
create a database link to the new domain
go to new database which you have reacted through phpmyadmin--delete all the tables which was installed by wordpress.
import that sql file which you have downloaded from old website
and in phpmyadmin change the url to new domain name
Regards
Follow these steps:
export database from phpmyadmin.
zip your WordPress project via c-panel.
upload zip file on new domain via c-panel.
extract zip file.
create new database and import old database in new phpmyadmin.
configure user name and password and database name.
change url in database table. from wp_operation table home_url and site_url
Thanks

moving WordPress over to domain, after working on it locally through MAMP

I've finished the styling changes on WordPress and I'm ready to move it from MAMP to my domain.
Will this involve any changes to the WordPress files or can I just drag it over to my new domain once I purchased it?
The main start you must make is update your wp-config.php
define('WP_HOME','http://www.mynewdomain.com');
define('WP_SITEURL','http://www.mynewdomain.com');
That way wordpress knows what domain it MUST run from.
The reason you do that is because without this you may not be able to access admin, login, etc etc.
When this is working and you have logged in, go to wp-admin and go to your permalink settings.
Make a NOTE of your settings, then change them to default (and woocommerce settings etc).
Go to your home page and a few others, and notice how messed up your urls look :)
Now go back to permalink settings and restore them (the point of this is to make sure your .htaccess file that wordpress depends upon is set correctly)
Finally, have a look at https://github.com/veloper/WordPress-Domain-Changer to change your sql etc if needed.
note this method is very handy for developers so you just update your wp-config.php for localhost or development or production (not for testing purposes, don't use your local pc. copy it all up to a subdirectory of your hosting partner e.g. http://www.mynewdomain.com/mytestarea. Make sure you use a COPY of the mysql database (never point both to the same database). You now can test on the hosting platform without disturbing the live site or your development causing issues to other people.
It's been a long while for me personally, but you'll want to change the SiteURL via the options menu in wp-admin.
Otherwise, just make sure your MySQL database is exported over, your credentials and user permissions are all setup and those work too.
If you still have problems:
https://codex.wordpress.org/Changing_The_Site_URL
https://codex.wordpress.org/Moving_WordPress
The database has to be updated. What always works for me is that I export the database from phpMyAdmin or MySQL (using mysqldump) and open the exported .sql-file with a text editor, like Sublime Text.
Now you want to find any occurence of your previous URL. Let's say on your dev machine the URL to the index of your Wordpress site is http://localhost:8080/wordpress and you want it to be on a website under https://domain.com you simply do a Find & Replace using that and replace everything with https://domain.com.
For older Wordpress versions you have to update the .htaccess files if you have custom URL's.
You have to make a search replace in your database and replace your local domain ( test.lo ) with the live domain ( test.com ).
To do this you can use the script from here: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Add the searchreplacedb2.php file in your route folder and the access test.lo/searchreplacedb2.php and follow the steps there. This will replace your local domain with your live one everywhere in the database.
You can't make a simple search-replace because the local domain might be serialized in some fields in the database, and a simple search-replace will not replace those.

Moved multisite from domain.com to localhost - Can't get it to work

I've copied the entire wordpress folder from a server to my local machine. I have also exported and imported our MySQL database which I can access just fine.
What settings do I need to modify in order to make the wordpress sites run on my computer?
So far I have done this:
Changed define('DOMAIN_CURRENT_SITE', 'domain.com') to define('DOMAIN_CURRENT_SITE', 'localhost.com') in wp-config.php
I've added 127.0.0.1 localhost.com to my hosts file
I've changed the row siteurl to localhost.com in the database table wp_options
But I'm not sure what else to change to make it work. Whenever I try to access localhost.com I get redirected to the url listed in wp_config.php define('NOBLOGREDIRECT', 'http://www.domain.com').
I'm using MAMP and accessing MAMP works fine. It's accessing the WP sites that trouble me. I don't know how/where to set the urls to make it work.
When you move a Wordpress database, you need to change all the references in the DB from your old domain name to the new one. Doing this manually is tricky as a lot of the data is serialized.
Luckily, someone has written a program that will do a search and replace of every piece of data in the DB and you can get it here:
search-and-replace-for-wordpress-databases
e.g. You should search for all occurrences of www.your-domain.com and replace them with localhost.com It's also worth checking for server paths, e.g. /home/my_name/public_html and change it to /Applications/MAMP/htdocs

Resources