1.
Download your existing site files.
2.
Export your database - go in to mySQL and export the database.
mysqldump --add-drop-table -h mysql_host -u mysql_user -p mysql_databasename > mysql_db.backup.sql
mysql -h mysql_host -u mysql_user -p myqsl_databasename < mysql_db.backup.sql
Important
Move the backed up files and database into a new folder - somewhere safe - this is your site backup.
3.
Log in to the site you want to move and:
- go to Settings > Permalinks and turn the Permalinks off
- go to Settings > General, then change the URLs. (ie from http://example.com/ to http://example.net ) - save the settings and expect to see a 404 page.
4.
Download your site files again.
5.
Export the database again.
6.
Edit wp-config.php with the new server's mySQL database name, user and password.
7.
Upload the files.
8.
Import the database on the new server.
9.
Use the
Search and Replace for WordPress Databases Script in order to search and replace the old URL and root folder references on your entire database.
eg.
from http://example.com/ to http://example.net
from /var/www/oldsite/ to /httdocs/newsite/
Source:
https://codex.wordpress.org/Moving_WordPress#Changing_Your_Domain_Name_and_URLs