Changing Site URL in WordPress Database

Changing Site URL in WordPress Database

Changing Site URL in WordPress Database, when migrating a WordPress website hosting or changing its domain, you often need to update the site’s URL in the database to ensure proper functionality. WordPress stores the site URL and home URL in the database, which defines where the site resides and where users should be directed. Failing to update these values can result in broken links, missing assets, or redirect issues. By accessing and editing the correct fields in the database, you can quickly update the URLs and restore smooth site operation

1. Access the Database via phpMyAdmin

  • Log in to your hosting account’s cPanel or hosting dashboard.
  • Go to phpMyAdmin (or another database management tool).
  • Select your WordPress database from the left sidebar.

2. Locate the wp_options Table

  • Find the table named wp_options in the list of tables (it may be prefixed with something other than wp_, such as wp123_options).

Open the options table

  • Click on the Browse button next to the wp_options table.

3. Changing Site URL in WordPress Database

In the wp_options table, look for the following two rows:

  • siteurl
  • home These values control the base URL of your WordPress site.
  • Step 1: Look for the row with the option_name siteurl.
    • Click Edit.
    • Update the option_value field with the new domain name or URL.
    • Click Go to save changes.
  • Step 2: Look for the row with the option_name home. for changing site URL in WordPress database
    • Click Edit.
    • Update the option_value field with the new domain or URL.
    • Click Go to save changes.
Changing Site URL in WordPress Database

4. Clear Browser Cache and Cookies

After making these changes, you may need to clear your browser’s cache and cookies to see the changes take effect.

5. Verify the Changes

After Changing Site URL in WordPress Database, Visit your site and check if it now reflects the new domain or URL. You can also log in to the WordPress dashboard and verify the site address under Settings > General.

Optional: Perform a Search-and-Replace

If your content still has old domain references, you can perform a search-and-replace in the database for Changing Site URL in WordPress Database using tools like:

  • Better Search Replace (WordPress plugin)
  • WP-CLI command line tool (wp search-replace)

This ensures all URLs, including media links, are updated to the new domain.

When Changing Site URL in WordPress Database, it’s important to take certain precautions to avoid breaking your site or losing data. Here are some key precautions:

  • Backup the Database
    Before Changing Site URL in WordPress Database, always take a full backup of your database. You can use plugins like UpdraftPlus or perform a manual backup via phpMyAdmin. This ensures you can restore the site if anything goes wrong.
  • Check for Hardcoded URLs
    Some themes or plugins might have hardcoded URLs pointing to the old domain. Before changing the URL, perform a search within your theme and plugin files to check for hardcoded URLs and update them accordingly.
  • Disable Caching Plugins
    If you’re using caching plugins like W3 Total Cache or WP Super Cache, clear the cache and temporarily disable the plugin. This ensures that you don’t encounter cached redirects or old settings.
  • Verify the Correct Database
    Ensure you’re editing the right WordPress database, especially if your server hosts multiple sites or databases. Check the wp-config.php file to confirm the correct database.
  • Update SSL Settings
    If you’re moving from http to https, make sure to install and update the SSL certificates correctly and adjust the WordPress site URL accordingly to use https://.
  • Clear Browser and DNS Cache
    After making changes, clear your browser cache and any DNS cache to ensure you are seeing the updated site.
  • Update Search Engine Settings
    After changing the site URL, update your settings in Google Search Console and submit a new sitemap to ensure search engines index the new domain properly.
  • Use Search and Replace
    Run a search-and-replace on your database to update all occurrences of the old domain. Use a safe tool like Better Search Replace to ensure all internal links, media, and settings point to the new URL.
  • Test Thoroughly
    After the change, check multiple pages of the site, both on the front-end and back-end, to ensure that all functionalities are working as expected, and no old URLs remain.
    By following these precautions, you can prevent potential downtime, data loss, or configuration issues during the URL change process in WordPress.