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