How To Clones or Migrate WordPress to another Domain Name and Fix Static Links

Some WordPress themes and plugins write the full URL of a site in their temporary files or database that makes it difficult to change the domain name of a wordpress installation.

In this guide I will clone WordPress xyz.com to abc.com/wordpress

This guide will cover the following 3 steps:
1- Clone or Migrate WordPress
2- Fix Static Links in Files
3- Fix Links and serialized strings in the database

1- Clone or Migrate WordPress

There are several ways to do this, you can
– Download all files and databases and reload them to the new server:

Just download the files of cPanel or FTP and the database of PhpMyAdmin and reload to new server

– Or transfer from & # 39; a server to & # 39; another using SSH without download / upload
on xyz.com server
Browse to the directory where wordpress is installed and running

mysqldump -u dbuser -p dbtable> db.sql

where dbuser is the username of db (usually found in wp.config)
dbtable is the table name
db.sql is a text file that contains all your database tables and data

zip -r wp.zip * .htaccess

This will zip / archive all the files, the database files that you extracted and the .htaccess files (which are needed if your web server is apache, litepeed.)

on abc.com/wordpress server
Sign in to your new server / host using SSH, go to the directory where you want to install WordPress and run the commands

wget xyz.com/wp.zip

This will download the files you’ve previously put in the previous step

Unzip wp.zip

to extract all files and db

mysql -u dbuser -p dbtable <db.sql

where dbuser is the database user you created on the new server
dbtable is the table name you created on the new server
db.sql is the file you extracted from wp.zip that was on the old server

vi wp-config.php

and change the database credentials for the new server (user, table, password)

Make sure you delete db.sql and wp.zip both servers

rm db.sql wp.zip

– Or copy files if both sites are on the same server and you have SSH access (you need root access if they are on another domain name)

on xyz.com server
Browse to the directory where wordpress is installed and running

mysqldump -u dbuser -p dbtable> db.sql

where dbuser is the username of db (usually found in wp.config)
dbtable is the table name
db.sql is a text file that contains all your database table

cp -R * / home / yourpath / yourpath
cp. htaccess / home / yourpath / yourpath

where / House / yourpath / yourpath is the path of your new installation / clone

on abc.com/wordpress server

mysql -u dbuser -p dbtable <db.sql

where dbuser is the database user
dbtable is the new table name
db.sql is the database file

vi wp-config.php

And change the database credentials for the new server (user, table, password), you can also do it from FTP

2- Fix Static Links in Files

This will be done by SSH

on abc.com/wordpress installation, run in SSH
find -name. php -exec sed -i & # 39; s;xyz.com;abc.com/wordpress; g “{}
find -name. js -exec sed -i & # 39; s;xyz.com;abc.com/wordpress; g “{}
find -name. css -exec sed -i & # 39; s;xyz.com;abc.com/wordpress; g “{}

Make sure you delete db.sql

rm db.sql

3- Fix Links and serialized strings in the database

The easiest way is to do this using a PHP program called Search and Replace.
Download it from
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

Extract and upload it to & # 39; a directory in your WordPress installation, example
abc.com/wordpress/searchr

and open it from your browser, it must locate the wp-config database information, make sure it is correct

Enter the domain name you want to replace and the new value

You can make a dry race to see which tables will be affected.

Once you’re done, do a live race.

Once live run is done, remove search and replace. You can either delete the folder you uploaded or remove it from the interface.

(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = “http://connect.facebook.net/en_US/all.js#xfbml=1&appId=463292747036958”;
fjs.parentNode.insertBefore(js, fjs);
}(document, ‘script’, ‘facebook-jssdk’));

this post was thanks to TECH AND DEV.

Excellent website on technology, I recommend you visit their site and see some of their articles.

THANK YOU FOR VISITING US AND CAN SUBSCRIBE TO OUR NEWSLESTER TO GET THE LATEST NEWS

ORIGINAL SOURCE LINK TECH AND DEV

Leave a Reply