Migrating a WordPress site to a new domain or server is a significant undertaking, often necessary for growth, branding changes, or performance upgrades. However, one of the most critical aspects of this process is ensuring that all URLs on your site are updated correctly. Failing to change URLs during a WordPress site migration can lead to broken links, lost traffic, and SEO penalties.

In this comprehensive guide, we’ll walk you through how to change URLs during a WordPress site migration, covering essential steps, best practices, and common challenges.
Why Changing URLs During Site Migration Matters
When migrating a WordPress site, URLs must be updated to reflect the new domain or server location. This process is essential for several reasons:
- Preserving SEO Rankings
If URLs aren’t updated correctly, search engines may encounter broken links or duplicate content, harming your rankings. - Avoiding Broken Links
Incorrect or outdated URLs can lead to 404 errors, frustrating users and reducing your site’s credibility. - Maintaining Internal Linking Structure
All internal links need to point to the new domain to ensure smooth navigation and user experience.
External link example: Learn more about URL redirection best practices from Moz.
Step-by-Step Guide to Changing URLs During a WordPress Site Migration
1. Prepare for the Migration
Before making any changes, ensure that you have a solid plan and a reliable backup of your website.
- Backup Your Site: Use plugins like UpdraftPlus to create a complete backup of your database, files, and media.
- Set Up a Staging Site: Test the migration on a staging environment before applying it to your live site.
2. Migrate Your Files and Database
Once your staging site or new server is ready, move your WordPress files and database.
- Export Database: Use phpMyAdmin or a plugin like WP Migrate DB to export your database.
- Transfer Files: Upload your WordPress files to the new server using an FTP client like FileZilla.
3. Update URLs in the Database
To change URLs in WordPress, you must update them in the database. This involves modifying entries in specific tables, such as wp_options
, wp_posts
, and wp_postmeta
.
Use phpMyAdmin:
- Log in to your hosting account and access phpMyAdmin.
- Select your WordPress database.
- Run SQL queries to update URLs:
UPDATE wp_options SET option_value = replace(option_value, 'http://oldurl.com', 'http://newurl.com') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET guid = replace(guid, 'http://oldurl.com','http://newurl.com'); UPDATE wp_posts SET post_content = replace(post_content, 'http://oldurl.com', 'http://newurl.com'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://oldurl.com','http://newurl.com');
4. Use a Plugin for Bulk URL Updates
If you’re not comfortable running SQL queries, WordPress plugins can simplify the process.
- Better Search Replace
This plugin allows you to search and replace URLs in your database without writing code. Download Better Search Replace. - Velvet Blues Update URLs
This plugin specifically targets URLs after migrations. Get Velvet Blues Update URLs.
Steps Using Better Search Replace:
- Install and activate the plugin.
- Navigate to Tools > Better Search Replace.
- Enter the old URL and the new URL in the respective fields.
- Select all tables in your database and run a test first.
- Execute the replacement after confirming the changes.
5. Set Up 301 Redirects
Implementing 301 redirects ensures that users and search engines are automatically directed from old URLs to new ones.
Use Your .htaccess File:
If you’re using an Apache server, add the following code to your .htaccess
file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^oldurl.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.oldurl.com [NC]
RewriteRule ^(.*)$ http://newurl.com/\ [L,R=301,NC]
Use a Redirection Plugin:
For a simpler solution, use a plugin like Redirection to manage 301 redirects from your WordPress dashboard.
6. Update Links and Media
After changing URLs, update all internal links and media paths to reflect the new domain.
- Use a Link Checker Plugin: Plugins like Broken Link Checker can help you identify and fix broken links.
- Update Media URLs: If your media files are hosted externally or use absolute URLs, update their paths in the database or re-upload them.
7. Update Permalinks
Re-saving your permalinks ensures that the new URLs are applied site-wide.
- Go to Settings > Permalinks in your WordPress dashboard.
- Select your preferred permalink structure.
- Save changes to regenerate the .htaccess file with the updated URLs.
8. Test Your Site
Once the migration is complete, thoroughly test your site to ensure everything works correctly.
- Check Pages and Posts: Navigate through your website to verify all pages are accessible.
- Validate Redirects: Use tools like Redirect Checker to confirm 301 redirects are working properly.
- Verify SEO Settings: Ensure that your metadata, sitemaps, and robots.txt file are updated for the new URLs.
Common Challenges and How to Overcome Them
1. Mixed Content Issues
When switching from HTTP to HTTPS, you might encounter mixed content warnings.
Solution: Use a plugin like Really Simple SSL to automatically fix insecure URLs.
2. Broken Links
After migration, some links may remain broken due to overlooked updates.
Solution: Regularly audit your site using tools like Screaming Frog.
3. Loss of Traffic
Temporary traffic dips are common after migrations.
Solution: Submit your updated sitemap to Google Search Console and Bing Webmaster Tools to expedite reindexing.
External link example: Check out Google’s site migration guidelines.
Best Practices for URL Changes During Migration
- Plan Ahead: Outline every step of the migration process to minimize errors.
- Test Thoroughly: Use a staging site to identify issues before launching the migration.
- Monitor SEO Performance: Track your rankings and traffic post-migration to ensure recovery.
- Communicate with Users: Notify your audience about the migration to manage expectations.
Final Thoughts
Changing URLs during a WordPress site migration is a delicate process that requires careful planning and execution. By following the steps outlined in this guide, you can ensure a smooth transition with minimal impact on SEO and user experience. Remember to test your site thoroughly, monitor performance, and address any issues promptly.
For more detailed guidance, explore the WordPress Codex on Site Migration, and start your migration journey with confidence!