How to Change Your WordPress URL and Fix Broken Image Links (Complete Guide)

Website Technical Support
Author: Leo MA
05/04/2026

Changing your WordPress website URL is a common task during domain migration or rebranding. However, if not handled correctly, it can lead to broken links, missing images, and site errors.

In this guide, we’ll walk you through:

  • How to safely change your WordPress site URL
  • How to update your database
  • How to fix broken image links after migration
  • Essential post-migration steps

Before You Start

Before making any changes, you should:

  • Ensure your new domain DNS is correctly pointed to your hosting
  • Take a full backup of your website and database
  • Confirm you have access to cPanel and phpMyAdmin

Failing to do so may result in data loss or site issues.


 

Step 1: Change Your WordPress URL

Method 1 (Recommended): Update via wp-config.php

This is the fastest and safest method.

Steps:

  1. Log in to cPanel
  2. Open File Manager
  3. Navigate to your WordPress root folder (usually public_html)
  4. Edit the file: wp-config.php
  5. Add the following code:
 
define(‘WP_SITEURL’, ‘https://your-new-domain.com’);
define(‘WP_HOME’, ‘https://your-new-domain.com’);
 

👉 Replace your-new-domain.com with your actual domain.


 

Method 2: Update via Database (phpMyAdmin)

If the first method doesn’t work, update your database directly.

Steps:

  1. Log in to cPanel → phpMyAdmin
  2. Select your WordPress database
  3. Open the table: wp_options
  4. Locate:
    • siteurl
    • home
  5. Update both values to your new domain

 

Step 2: Fix Broken Image Links

After changing your domain, images may still point to the old URL, causing them not to load.

This happens because WordPress stores image URLs inside the database.

Fix Using SQL (Recommended)

Steps:

  1. Go to cPanel → phpMyAdmin
  2. Select your database
  3. Click the SQL tab
  4. Run the following query:
 
UPDATE wp_posts SET post_content = REPLACE(post_content, ‘old_url’, ‘new_url’);
 

👉 Replace:

  • old_url → your old domain
  • new_url → your new domain

 

Important Warning

  • Always back up your database before running SQL queries
  • Incorrect queries can break your entire website

 

Step 3: Update Remaining URLs (Search & Replace)

Even after fixing images, your database may still contain old URLs in:

  • Pages
  • Posts
  • Theme settings
  • Plugins

Recommended solution:

Use a search-and-replace plugin to update all remaining references.


 

Step 4: Clear Cache

If your site uses caching plugins (e.g. WP Super Cache, W3 Total Cache), clear all caches.

Otherwise, changes may not appear immediately.


 

Step 5: Elementor Users (If Applicable)

If your website uses Elementor:

  1. Go to Elementor → Tools → Replace URL
  2. Enter:
    • Old URL
    • New URL
  3. Click Replace URL
  4. Go to General → Regenerate CSS

 

Step 6: Final Checks

After completing everything:

  • Verify your site loads correctly
  • Check images and internal links
  • Re-save permalinks (Settings → Permalinks)
  • Test forms and functionality

 

Common Issues After URL Change

1. Broken images

✔ Fix using SQL replace query

2. Mixed content (HTTP/HTTPS)

✔ Ensure SSL is installed and URLs use HTTPS

3. Redirect loops

✔ Check .htaccess and caching plugins

4. Missing styles (CSS)

✔ Regenerate CSS (especially for Elementor)


 

Pro Tips

  • Always perform migrations on a staging environment first
  • Use 301 redirects to preserve SEO
  • Update Google Search Console after domain change
  • Keep backups before and after changes

 

Conclusion

Changing your WordPress URL is straightforward when done correctly, but it involves more than just updating a domain. You must also:

  • Update database references
  • Fix image links
  • Clear caches
  • Test your entire site

Following this process ensures a smooth migration with no broken content or SEO loss.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top