Updating URLs in WordPress (Firstserv Guide)

When changing your website’s domain name or moving from a staging environment to a live site, it’s essential to update all URLs. This ensures that links, images, and other resources point to the correct location and your website functions properly.

Below are two common methods: using a plugin (recommended) or using WP-CLI via SSH.


Option 1: Using a Plugin (Recommended for Most Users)

Step 1: Install the Plugin

  1. Log in to your WordPress dashboard
  2. Go to Plugins → Add New
  3. Search for “Better Search Replace”
  4. Click Install Now, then Activate

Step 2: Run a Search and Replace

  1. Navigate to Tools → Better Search Replace
  2. Enter:
    • Search for: your old URL (e.g. staging.yoursite.com)
    • Replace with: your new URL (e.g. yoursite.com)
  3. Select the relevant database tables (typically all tables)

Step 3: Perform a Test Run

  • Enable the Dry Run option
  • Run the tool to preview how many changes will be made (no changes applied yet)

Step 4: Apply Changes

  • If the results look correct:
    • Disable Dry Run
    • Click Run Search/Replace

Step 5: Clear Cache

After completing the update:

  • Clear your caching plugin (e.g. LiteSpeed Cache)
  • Clear any browser or CDN cache

✅ This ensures your updates take effect immediately.


Option 2: Using WP-CLI (Advanced Users)

If your hosting includes SSH access, you can use WP-CLI for a faster, command-line approach.


Step 1: Access Terminal

  1. Log in to cPanel
  2. Open Terminal (under the Advanced section)
  3. Launch the terminal environment

Step 2: Navigate to Your WordPress Directory

 
 
 
 
 
 
Shell
 
 
cd public_html
 
 

(Adjust this path if your WordPress installation is in a different directory.)


Step 3: Preview Changes (Recommended)

Run a dry run to see what will be updated:

 
 
 
 
 
 
Shell
 
 
wp search-replace 'staging.yoursite.com' 'yoursite.com' --dry-run
 
 

Step 4: Apply Changes

Once you’re satisfied with the preview:

 
 
 
 
 
 
Shell
 
 
wp search-replace 'staging.yoursite.com' 'yoursite.com' --all-tables
 
 

Step 5: Clear Cache

  • Clear any WordPress caching plugins
  • Flush server or CDN cache if applicable

Important Tips

  • ✅ Always back up your database before making bulk changes
  • ✅ Ensure consistency (update http:// to https:// if needed)
  • ✅ Test your website thoroughly after making changes

Summary

Updating URLs is a key step when migrating or renaming your WordPress site. You can:

  • Use a plugin for a simple, user-friendly approach
  • Use WP-CLI for a faster, more advanced method

If you need assistance updating your URLs or migrating your website, the Firstserv support team is always available to help.

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to install the Wordpress Litespeed cache plugin

  LiteSpeed Cache – What It Is and How It Helps If you’re running a WordPress website and...

How to disable the WordPress CRON job and set it up in cPanel

  Optimising WordPress Cron (wp-cron) – Firstserv WordPress does not...

Fixing WordPress mixed content issues

  Fixing Mixed Content Warnings When you visit a website using https://, your browser expects...

How to optimise your WordPress site

Optimising Your WordPress Website (Firstserv Guide) WordPress is a...

Configuring Redis Object Caching using Litespeed Cache

Object Caching and Redis (Firstserv Guide) What is Object Caching? Object caching is a...