Changing your WordPress site URL may be necessary for various reasons, such as switching to HTTPS, changing your domain name, migrating from a local server to a live site, or transferring to a subdomain. Before making any changes, ensure you create a complete backup of your website.
Steps to Change Your WordPress Site URL
1. Change the URL in Your WordPress Admin Dashboard
This method is straightforward and often sufficient for changing your domain name.
Log in to your WordPress admin dashboard.
Go to Settings → General.
Update the WordPress Address (URL) and Site Address (URL) fields with your new domain name. Both should be the same.
Click Save Changes.
Visit your website to ensure everything works correctly.
2. Using the wp-config.php
File
If the URL is hardcoded in the wp-config.php
file, you’ll need to change it there.
Connect to your website using an FTP client.
Locate the wp-config.php
file in the root folder of your website.
Add the following lines above the line that says /* That's all, stop editing! Happy publishing. */
:
Replace https://newdomain.com
with your new domain name.
Save and upload the file back to your server.
Visit your website to verify that everything is working.
3. Using the functions.php
File
If you cannot access the admin panel, you can change the URL through the functions.php
file.
Connect to your WordPress site using an FTP client.
Navigate to your theme folder, typically located in /wp-content/themes/your-theme-folder/
.
Open the functions.php
file with a text editor and add the following lines at the bottom:
update_option( 'siteurl', 'https://newdomain.com' );
update_option( 'home', 'https://newdomain.com' );
Replace https://newdomain.com
with your own URLs.
Save and upload the file back to your server.
Once your website is functioning properly, remove the added lines from functions.php
.
4. Using SSH
If you have SSH access enabled in your cPanel:
Log into your cPanel and navigate to Advanced > Terminal.
Change to your website directory:
Run the command to replace the old URL with the new one:
5. Using phpMyAdmin
If you lack access to the admin dashboard or Terminal, you can update the URLs directly in your database.
- Log into your cPanel and locate your database in the
wp-config.php
file. - Click on phpMyAdmin under the Databases section.
- Select your database and navigate to the
wp_options
table. - Locate the
option_name
column, findsiteurl
andhome
, and click the Edit icon next to each. - Change the
option_value
to your new site URL and click Go to save changes. - Visit your website to confirm everything is functioning.
Note: Some references in the database may not update automatically. If needed, update all links as follows:
- Backup your database.
- Open the
.sql
file with a text editor and use the Find and Replace feature to update all URL references. - Save the changes and import the updated database back into phpMyAdmin.
6. Using WP-CLI
If you prefer the command line:
Use the following commands to change your site URL:
Replace newdomain.com
with your actual domain.
Conclusion
You have several methods to change your WordPress site URL, including adjusting settings in the admin dashboard, modifying configuration files, editing the database, or using WP-CLI. Choose the method that suits your needs best, and your new WordPress URL will be up and running swiftly.