Methods to Change the WordPress Site URL
Method1: Change the WordPress Site URLs from Admin Area
In order to change the wordpress site URL,
- go to the wordpress dashboard.
- Then go to settings and click on the General tab.
- Here, you will get two options ‘WordPress site URL’ and ‘Site address.
- You can change the URLs of these. Both of these must be the same.
- Then, click on the ‘Save Changes‘ button.
- Once you check whether it is working correctly or not.
Method2: Using Functions.php file
The one who can not access their wordpress admin area, you can use this method.
- Go to /wp-content/themes/your-theme-folder/.
- Here, you need to find the functions.php file
- and edit this file using a text editor like a notepad.
- Then, you need to enter the following code at the end.
update_option(
'siteurl'
,
'https://example.com'
);
update_option(
'home'
,
'https://example.com'
);
- Write your site URL in place of https://example.com.
- Then, save the changes you made
- and upload the file back to the wordpress hosting using FTP.
You can visit your website whether everything working correctly.
Once everything is done, don’t forget to remove the two lines of code from your wordpress functions.php file.
Method3: Using the wp-config.php file to change the wordpress site URL
- you need to add the site URLs to your wordpress configuration file that is wp-config.php.
- This is available under the root folder of your website and contains important settings.
- Connect to your wordpress site using FTP client,
- and change the wp-config.php file.
- You need to add the below code just above the line ‘That’s all, stop editing! Happy publishing’.
define(
'WP_HOME'
,
'https://example.com'
);
define(
'WP_SITEURL'
,
'https://example.com'
);
- Write your domain name in place of https://example.com.
- Save the changes you made
- and upload them back to the server.
- Once you visit your site to check whether it is working correctly.
Method4: Change WordPress Site URLs in Database Using phpMyAdmin.
You need to backup your wordpress database. This is useful because if anything goes wrong, it will undo the database changes.
- Log into your web hosting account’s dashboard.
- Then, click on the phpMyAdmin icon available under the database section.
- In the phpMyAdmin interface, click on the WordPress database in the left column,
- Click on the wp-options table.
- It will display the rows inside the wp-options table.
- You need to find the row where option_name is site URL and home.
- Then click on the edit option
- and change the option_value field to the new site URL.
- Then, click on the Go button to save changes.
Leave a Comment