There may be several reasons as to why you might have to change your URL. The most prevalent reason is when you do not have access to the previous location or do not have access to the WordPress admin area.
Other reasons
- When a WordPress site has been moved to the parent domain from the sub-directory. You won’t be able to login with the new URL since WordPress is configured to use the old URL.
- When you want to add or remove www from your domain. You may see browser redirecting error after you have made the changes to the URL.
- The first part of the URL changes from Http to Https if you are using an SSL certificate.
- When you have moved your site to a new domain from your previously hosted domain.
If your reasons are one of the above and you are not able to login to your dashboard, you can use Phpmyadmin to change your home and site URLs.
Caution – Before making any changes, ensure that you have a backup of your WordPress database. In case of a mistake, you can restore this backed up data and try again.
How to change your WordPress URL in MySQL database using phpMyAdmin.
The first step is to determine the name of your WordPress MySQL Database.
You can skip through this part if you only have one MySQL database. Follow these steps if you have multiple databases. WordPress stores MySQL database credentials in the wp-config.php file. This file is found in your root file directory.
- Access your Cpanel and open File manager. Choose the domain name and click on Go to file manager.
- Open the wp-config.php and look for DB_NAME aka your database name.
Changing the WordPress URLs
Changing your old URL is not at all a difficult task. This is what you need to do:
- Through your website control panel, go to phpMyAdmin.
- All your databases will be listed in the left panel. Select the database connected to your WordPress site and navigate to the SQL tab.
- Type in the below SQL query :
UPDATE wp_options SET option_value = replace(option_value, ‘oldurl.com’, ‘newurl.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;UPDATE wp_posts SET guid = replace(guid, ‘oldurl.com’,’newurl.com’);UPDATE wp_posts SET post_content = replace(post_content, ‘oldurl.com’, ‘newurl.com’);
UPDATE wp_postmeta SET meta_value = replace(meta_value,’oldurl.com’,’newurl.com’);
Replace the oldurl.com with your current address and the newurl.com with your new WordPress address.
- And hit Go. Success messages will be shown along with the number of changed rows.
- Now, we just need to verify the changes. Open the wp_options table to check the option_value of home and site URL. The new URL must be visible.
Now, try accessing your site from the new URL. You may need to update certain links which are still using your old URL. Make use of a plugin to update all these.
You should now be able to log into your site without worries.
Found this article helpful? Let us know!
Share Your Comments & Feedback