How to update/change the WordPress site URLs through PhpMyAdmin in cPanel.

How to update/change the WordPress site URLs through PhpMyAdmin in cPanel.

Why You Might Need to Change the WordPress Site URL

Changing the WordPress site URL is necessary in several scenarios:

Case #1: Moving from a Subdirectory

  • Scenario: You’re moving your WordPress site from a subdirectory (e.g., http://example.com/blog) to the root domain (http://example.com).
  • Issue: After the move, you may be unable to log in because WordPress is still configured to use the old URL.

Case #2: Adding or Removing ‘www’

  • Scenario: You want to switch your domain from example.com to www.example.com, or vice versa.
  • Issue: If not done correctly, this change could lead to redirect errors like “Too many redirects” or “The page isn’t redirecting properly.”

Case #3: Adding ‘https’ to the URL

  • Scenario: You’re adding an SSL certificate, so your URL changes from http:// to https://.
  • Issue: If the URL isn’t updated, you may face issues logging in, as WordPress will still use the old http URL.

Case #4: Moving to a New Domain

  • Scenario: You’re moving your WordPress site to a completely new domain (e.g., from http://example.com to http://demo.com).
  • Issue: The site will continue to reference the old domain, causing login and access issues.

Development to Live Site: If you’ve developed your site on a local or staging environment (e.g., localhost or staging.example.com), you’ll need to update the URL when moving the site to its live domain.

URL Corrections: If there’s a typo in your site URL, or if it was set incorrectly during installation, you might need to change it.

SEO and Branding: Updating the site URL can be part of an SEO or rebranding effort to improve search engine rankings or align with a new brand identity.

Fixing Broken URLs: If your site URLs are broken or not correctly pointing to your content, updating the WordPress site URL might resolve these issues.

Follow the steps below to change the WordPress site URL from phpMyAdmin:

If you’ve implemented any of the changes listed, you won’t be able to access your dashboard. Instead, you’ll need to update the HOME and SITE URLs via phpMyAdmin.

1.Login to your cPanel account.

2.In search bar search the phpMyAdmin

3.In the left pane, select your database. A list of several tables will appear below it. Locate and click on the wp_options table.

4.Find the rows labeled siteurl and home. To edit them, click the pencil icon next to each one.

5.When you hover over these options, you’ll see “Browse.”

6.Enter the new URL to replace the existing one.

7.Click the “Go” button to save the changes. Repeat this process for both the siteurl and home options.

Once this is completed, you’ll be able to log in to your site at example.com/wp-login.php.

Although you’ll have access to your site, some URLs in your database might still use the old URL. You’ll need to update all instances of the old URL to the new one throughout the database.

Option 2 – Changing the URLs in your wp-config.php file

Access your WordPress installation’s root directory. You can do this through FTP or your hosting control panel. If you’re using cPanel, search for “File Manager” and open it. Navigate to the public_html directory to find your files and folders.

Locate the wp-config.php file and open it in a text editor.

3.Add the following lines to the file, replacing http://new-url.com with your new URL:

define(‘WP_HOME’, ‘http://new-url.com’);

define(‘WP_SITEURL’, ‘http://new-url.com’);

4.Save the changes and upload the updated wp-config.php file back to your server.

This method sets the new URL directly in your configuration file, overriding the database settings.

You’ll have instant access to your site, but the database won’t have the correct HOME and SITE URL settings. It’s crucial to update all URLs in the database to reflect the new URL.

Confirming the updated HOME and SITE URL

If you’ve used the first option, ensure that the HOME and SITE URLs are updated in the database. Verify the correct URLs in your WordPress dashboard:

  1. Log in to your WordPress Dashboard.
  2. Navigate to Settings > General.

3.Here, you can view the HOME and SITE URLs that your WordPress site is configured to use.

Note: If you used the second option, the database will not update your HOME and SITE URLs. Instead, go to the Settings > General page where all the entries will be grayed out, reflecting the values entered in your wp-config.php file.

After updating, remove the lines from your wp-config.php file. Then, revisit the Settings > General page and ensure that the fields are no longer grayed out.

This is how you can change the WordPress site URL.