Method 1: Editing MySQL backup
To change the WordPress site URL, backup your MySQL database.
mysqldump -u USERNAME -p WP_DB_NAME > db.sql
Run sed command to replace the URL in MySQL backup file.
sed -e 's/OLD_URL/NEW_URL/gi' db.sql > db-modified.sql
Restore the new db-modified.sql, which will have the database with the URL changed.
mysql -u USERNAME -p WP_DB_NAME < db-modified.sql
Method 2: Using Plugin
Edit your wp-config.php and add the following line.
define('WP_HOME','https://yourdomain.com');
define('WP_SITEURL','https://yourdomain.com');
if you want the site available on multiple URL
define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/');
You can also edit the wp_options table
update wp_options set option_value="https://yourdomain.extn" where option_name="siteurl" or option_name="home";
Now you need to use some WordPress plugins to change URLs in the database, here are some useful plugins for changing site URL.
See WordPress
Leave a Reply