Skip to main content

How to Update WordPress URLs After a Domain or Hosting Change

After moving your website to a new domain or a new hosting provider, you must update the internal URLs within your WordPress database. This ensures that internal links, images, and site paths point to the correct location.

After moving your website to a new domain or a new hosting provider, you must update the internal URLs within your WordPress database. This ensures that internal links, images, and site paths point to the correct location.

Before you begin

You will need:

  • Site Administrator access to the WordPress dashboard.

  • Access to a database management tool (such as phpMyAdmin) or a search-and-replace plugin.

  • A full backup of your WordPress database before performing any search-and-replace operations.

Update URLs via a Search and Replace Plugin

The most common way to update URLs is by using a plugin that can handle serialized data in the database.

  1. Install and activate a search-and-replace plugin (such as "Better Search Replace").

  2. In your WordPress dashboard, navigate to Tools > Better Search Replace.

  3. In the search for field, enter your old URL (e.g., http://old-domain.com).

  4. In the replace with field, enter your new URL (e.g., https://new-domain.com).

  5. Select the tables you wish to perform the search on (selecting all tables is standard).

  6. Leave Dry Run checked initially to see how many occurrences will be changed.

  7. If the count is correct, uncheck Dry Run and click Run Search/Replace.

Update URLs via phpMyAdmin

If you prefer not to use a plugin, you can update the core site information directly in the database.

  1. Log in to your hosting control panel and open phpMyAdmin.

  2. Select your WordPress database from the left-hand sidebar.

  3. Locate the wp_options table (the prefix may vary, such as wp_ or wp_site_).

  4. Find the rows for siteurl and home.

  5. Edit the option_value for both rows to your new URL (e.g., https://new-domain.com).

  6. Click Go to save the changes.

Update URLs via wp-config.php (Temporary Fix)

If you are in the middle of a migration and need to force the site to load on the new domain while you perform manual updates, you can hardcode the URLs.

Warning: Hardcoding these values in your configuration file will prevent you from changing the site URL via the WordPress dashboard until the lines are removed.

  1. Access your site's root directory via FTP or a File Manager.

  2. Open the wp-config.php file.

  3. Add the following lines before the "That's all, stop editing!" line:

    define( 'WP_HOME', 'https://new-domain.com' );
    define( 'WP_SITEURL', 'https://new-domain.com' );

Confirm the result

  • Navigate to your website's homepage and verify that images and internal links load correctly.

  • Log in to the WordPress dashboard to ensure you can access all pages.

  • Check the Settings > General page to confirm the WordPress Address (URL) and Site Address (URL) reflect the new domain.

Limitations

  • Serialized Data: Using the wp-config.php method or a standard SQL query in phpMyAdmin may break "serialized" data used by some page builders or complex plugins. If your site layout appears broken after a manual SQL update, use a dedicated search-and-replace plugin to fix the serialization.

  • Caching: If you do not see changes immediately, clear your browser cache and any server-side caching (such as LiteSpeed or a plugin-based cache).

Did this answer your question?