- Log into your WordPress admin dashboard
- Click on Settings → General.
- Update WordPress Address (URL) line and Site Address (URL) lines with your new domain name. Both of these fields(Site Address and WordPress Address URL) should be the same.
- Save changes
- Visit your website to make sure everything is working as it should.
website.
To change this file you need to connect to your website using an FTP client.
- Locate the wp-config.php file, which can be found in the root folder for your domain.
- You need to add the code below just above the line that says ‘That’s all, stop editing! Happy publishing’.
define( ‘WP_SITEURL’, ‘https://examplesite.com’ );
- You will need to replace ‘https://examplesite.com’ with your new domain name.
- Save changes and upload the file back to your server.
Visit your website to make sure that everything is working fine.
- Using an FTP client, you can connect to your WordPress site
- Locate your WordPress theme folder. For most users, this will be something like /wp-content/themes/your-theme-folder/.
- Locate functions.php file via FTP
- using your preferred text editor like Notepad, open your functions.php file and edit it
- Add the code below to the bottom of the file.
update_option( ‘home’, ‘https://examplesite.com’ );
Replace ‘https://examplesite.com’ with your own site URLs.
- Save changes and upload the file back to your server using FTP.
Visit your website to make sure everything is working as it should.
- Enable SSH access in your cPanel using this guide.
- Log into your cPanel > Advanced > Terminal:
- Find your website directory using the command below:
- Where the root directory is the main folder of your installation (e.g., public_html for the main domain).
- Run the command below:
- Log into your cPanel
- Locate the database associated with your website in wp-config.php file
- Click phpMyAdmin in the ‘Databases’ section.
- Click on the database in the left-side column and wp-options(by default wp_ is the database prefix but it can be different for your installation)
- You will see rows inside the options table. You need to locate the ‘option_name’ column where ‘siteurl’ and ‘home’ will be listed.
- Click on the pencil ‘Edit’ icon to the left of each row and change the ‘option_value’ field to your new site URL.
- Click the ‘Go’ button in the bottom right corner to save your database changes.
- Locate the database associated with your website in wp-config.php file
- Right-click on wp-config.php > View or Edit option:
- Download the backup of the database. You can take a backup from within your cPanel > Files section > Backup menu
- Open .sql file with some text editor and update all URL references
- Using Ctrl + F and select Replace option.
- Fill in the corresponding fields
- Replace your old domain with your new domain and click Replace All:
- Save changes.
- Upload the updated database using the phpMyAdmin menu in the Databases section
- Select the newly created database from the list on the left and use the switch to Import tab. Import the database .sql file from your local device
- Once done, you will need to update the wp-config.php file in your installation root folder:
define ‘DB_NAME’ line – the name of the new database you’ve created in MySQL Databases menu.
define ‘DB_USER’ line – the name of the new user you you’ve created in MySQL Databases menu.
define ‘DB_PASSWORD’ line – the new password you’ve set for database user in MySQL Databases menu.
- Save changes.
- Delete the old database once you confirm that everything is working fine
- Proceed to your WordPress admin page to re-generate the permalinks to make sure they have the new URL.
- Log into your WordPress dashboard in the Settings menu > Permalinks.
- If you had a Post name, switch it to Plain
- Save changes and then revert everything back
wp option update home ‘http://examplesite.com’
wp option update siteurl ‘http://examplesite.com’
Replace “examplesite” text with your existing domain to get this done! You have a number of methods to choose from to change your WordPress URL You can change the settings in the WordPress admin, hardcode them in your wp-config.php file, edit the database, use WP-CLI or use a plugin
. Work through the methods above to find the one that suits your site, and you’ll have your new WordPress URL working in no time.