How to Bulk Update WordPress URLs After Changing Domain Name

So you’ve changed your WordPress site’s domain name — congratulations! Whether it’s for rebranding, SEO improvement, or just a better web address, switching to a new domain feels like a big step forward. But there’s one major hurdle: updating all the old URLs tied to the previous domain. If you don’t handle this transition correctly, you risk broken links, missing images, and even SEO issues.

Don’t worry. There are efficient ways to bulk update WordPress URLs after changing your domain name. In this guide, we’ll walk you through the most effective methods — using plugins, SQL queries, and some helpful tools — to ensure a smooth and error-free transition.

Why It’s Important to Update URLs After Changing Domains

When you migrate your site to a new domain, WordPress still retains the old URLs inside your database. This includes:

  • Internal links
  • Permalinks
  • Image paths
  • File links
  • Widgets and metadata

If you fail to update these URLs, users will click on links that direct them to your old domain, leading to a poor user experience. It also signals to search engines that your site is inconsistent, which can negatively impact SEO rankings.

Pre-Migration Steps: Backup First!

Before making any changes to your database, it is critical to back up your entire website. This includes both your WordPress files and your database.

Popular backup plugins:

  • UpdraftPlus
  • BackupBuddy
  • Duplicator

Alternatively, if you’re tech-savvy, use phpMyAdmin or a server-based solution to manually back up your MySQL database. It might feel tedious, but this step can save you a headache in case something goes wrong.

Method 1: Use a WordPress Plugin to Update URLs

The easiest and most beginner-friendly way to bulk update URLs is by using a WordPress plugin. Here are two of the most popular options:

1. Better Search Replace

This plugin allows you to search and replace any string in your WordPress database.

Steps to use Better Search Replace:

  1. Install and activate the plugin from the WordPress plugin repository.
  2. Go to Tools > Better Search Replace.
  3. Enter your old domain (e.g., http://oldsite.com) in the “Search for” field.
  4. Enter the new domain (e.g., http://newsite.com) in the “Replace with” field.
  5. Select all tables (or just wp_posts to begin with, if you want to be cautious).
  6. Check the “Run as dry run?” checkbox first to preview changes.
  7. If everything looks good, uncheck dry run and execute the replacement.

2. Velvet Blues Update URLs

This is another easy-to-use plugin designed to update URLs when your site domain name changes.

How to use:

  1. Install and activate Velvet Blues Update URLs.
  2. Go to Tools > Update URLs.
  3. Enter the old and new URLs.
  4. Choose the types of URLs you want to update (e.g., posts, pages, excerpts).
  5. Click “Update URLs NOW.”

This plugin provides a simple, no-fuss interface effective for small to medium-sized websites.

Method 2: Run SQL Queries in phpMyAdmin

If you’re comfortable working with databases, you can execute SQL queries directly in phpMyAdmin to bulk update your URLs. This method is powerful and fast but should be used with caution.

Accessing phpMyAdmin:

  • Log into your hosting control panel (e.g., cPanel).
  • Go to phpMyAdmin.
  • Select your WordPress database.

Sample SQL query:

UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://oldsite.com', 'http://newsite.com');

This command replaces your old domain with the new one inside post content. But remember, WordPress stores URLs in many different tables.

Additional useful queries:

UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'http://oldsite.com','http://newsite.com');
UPDATE wp_options SET option_value = REPLACE(option_value, 'http://oldsite.com', 'http://newsite.com');
UPDATE wp_guid SET guid = REPLACE(guid, 'http://oldsite.com','http://newsite.com');

Tip: Always double-check the prefix “wp_” — some sites use custom prefixes for added security.

Method 3: Use WP-CLI for Advanced Users

If you prefer command line interfaces, WP-CLI is an excellent tool for performing bulk actions on your WordPress install, including URL replacement.

Basic command to run:

wp search-replace 'http://oldsite.com' 'http://newsite.com' --dry-run

This will simulate the process. Remove --dry-run to apply the changes:

wp search-replace 'http://oldsite.com' 'http://newsite.com'

WP-CLI searches through every table in the database and replaces the identified string values efficiently — ideal for large multisite installations or custom setups.

Other Considerations

1. Fix Hardcoded URLs in Theme Files

If you (or your developer) manually inserted full URLs into your theme files, those won’t be updated by database changes. You’ll need to manually edit your theme files to reflect the new URLs.

2. Update the .htaccess File for Redirects

Use 301 redirects to tell search engines that the domain has permanently changed, which helps preserve your SEO rankings.

Redirect 301 / http://newsite.com/

Add this rule in your old domain’s .htaccess file to redirect all traffic to the new domain.

3. Inform Google Search Console

Don’t forget to set up the new domain on Google Search Console and notify Google about the domain change. Use the “Change of Address” tool under the site’s settings. This helps maintain search engine rankings and indexing.

Test Thoroughly

After making all these updates, go through your website thoroughly. Click on links, check image displays, test dashboards, and examine forms and widgets. Use a crawler tool like Screaming Frog or an online broken link checker to ensure all URLs now point correctly to your new domain.

Final Thoughts

Changing your WordPress domain name can seem intimidating, but with the right tools and safety precautions in place, you can do it without unnecessary stress. Whether you prefer using a plugin or diving into SQL and WP-CLI territory, there’s a method that suits every level of technical expertise. The most important part is taking a methodical and careful approach to ensure nothing gets lost in translation.

By updating your URLs properly, you ensure a seamless experience for both users and search engines. With everything correctly aligned, your new domain name will carry your site forward with professionalism, clean functionality, and SEO intact.

Happy migrating!

Leave a Reply