Home » Products » Hosting » Wordpress Hosting » How to Change URL in WordPress After Moving to a New Domain
This guide explains how to properly change your WordPress URL after moving to a new domain using settings, plugins, wp-config, and database edits. It also covers 301 redirects, cache updates, and SEO preservation. Avoid common pitfalls and ensure a smooth, error-free migration with the right tools and support. |
Changing a website’s domain isn’t just a technical task. It’s a shift in identity. But while the decision to move to a new domain might come with excitement and strategic purpose, the behind-the-scenes mechanics, especially in WordPress, require precision.
A domain shift without properly updating your WordPress URLs is like moving house but leaving your address unchanged at the post office. The content’s still there, but visitors, links, and search engines keep ending up at the old doorstep. The result? Confused users, broken links, missing media, and a potential SEO nosedive. And to put things into perspective, more than 1 in 5 WordPress users switch domains within the first two years.
So if you’ve landed here, chances are you’ve already made the move or you’re planning to and want to avoid that mess entirely. This blog covers how to change URL in WordPress using multiple reliable methods, while pointing out common pitfalls, overlooked tweaks, and strategies to make the whole process smooth and future-proof.
Step 1: Start with the Basics — Update Site URL in WordPress Settings
If you still have access to the WordPress dashboard after migration, this is the first place to start.
- Go to Settings > General in your WordPress admin panel.
- Update the WordPress Address (URL) and Site Address (URL) fields with your new domain.
- Click Save Changes.
WordPress will log you out immediately and attempt to reload from the new domain. If everything is set up correctly on your hosting side, your dashboard should load smoothly from the new address.
But this only changes what’s displayed on the frontend and a handful of backend settings. Much of your content—images, post links, and menus—still points to the old domain. You’ll need to go deeper.
Step 2: When the Dashboard Isn’t Available — Use wp-config.php
If your admin panel is out of reach due to misconfiguration, you can override the WordPress URL settings by editing the wp-config.php file.
- Use FTP or your hosting provider’s file manager to access your WordPress installation.
- Open wp-config.php, usually found in the root directory.
- Add these two lines, just before the comment that tells you to stop editing:
define(‘WP_HOME’, ‘https://yournewdomain.com’);
define(‘WP_SITEURL’, ‘https://yournewdomain.com’);
- Save the file and refresh your site.
This method enforces the new domain at a system level, bypassing settings in the database. While it’s not meant to be permanent, it helps get things working again so you can address deeper issues.
Step 3: Use a Plugin to Replace Old URLs Throughout the Database
This is where most migrations fall apart. Even after updating the site URL, internal links and embedded resources often continue pointing to the old domain. The fix? A search-and-replace operation that combs through the database.
Install a plugin like Better Search Replace or WP Migrate DB:
- After activating the plugin, go to Tools > Better Search Replace.
- Enter your old domain (e.g., http://oldsite.com) in the “Search for” field.
- Enter your new domain (e.g., https://newsite.com) in the “Replace with” field.
- Select all database tables for the operation.
- Run a dry test first to ensure no unintended data is affected.
- Then run the full replacement.
This process ensures that every mention of your old URL, in posts, metadata, widgets, and even custom fields, gets replaced with the new one.
Step 4: Use phpMyAdmin to Update the URL Manually (Advanced)
If you prefer manual control or the plugin route feels heavy-handed, you can update URLs directly from the database using phpMyAdmin.
Access your hosting panel and open the correct WordPress database:
UPDATE wp_options
SET option_value = replace(option_value, ‘http://oldsite.com’, ‘https://newsite.com’)
WHERE option_name = ‘siteurl’ OR option_name = ‘home’;
You’ll also want to update URLs in posts, attachments, and metadata:
UPDATE wp_posts
SET guid = replace(guid, ‘http://oldsite.com’,’https://newsite.com’);
UPDATE wp_posts
SET post_content = replace(post_content, ‘http://oldsite.com’, ‘https://newsite.com’);
UPDATE wp_postmeta
SET meta_value = replace(meta_value,’http://oldsite.com’,’https://newsite.com’);
Step 5: Set Up 301 Redirects from Old Domain to New Domain
To preserve SEO rankings and user access, every visitor to the old domain should be smoothly redirected to the equivalent page on the new domain.
If you’re using Apache, modify your .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^oldsite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.oldsite.com$
RewriteRule ^(.*)$ https://newsite.com/$1 [R=301,L]
This ensures that search engines know the change is permanent, and users aren’t stranded on outdated links.
Also Read: Easy Steps for Domain Transfer Without Downtime |
Step 6: Update Permalinks, Cache, and Everything Else
Once the main URLs and redirects are in place, take care of the smaller details. These often make the difference between a good migration and a flawless one.
- Go to Settings > Permalinks and click Save to flush rewrite rules.
- Clear your website’s cache using your caching plugin.
- Purge your browser cache or test in incognito mode.
- Update your sitemap and resubmit it to Google Search Console.
- Reconnect your site to tools like Google Analytics or Facebook Pixel using the new domain.
- Update your URLs across all marketing channels, newsletters, social media bios, and partner backlinks.
Also Read: Best Domain for Personal Website: Common Mistakes to Avoid |
Bonus Tip: Don’t Forget Mixed Content Issues
If you switched from HTTP to HTTPS along with your domain, be prepared to hunt down and fix mixed content warnings. These occur when some of your resources (like images or scripts) still load from HTTP.
Use a plugin like Really Simple SSL to scan your site and force HTTPS across all assets.
Common Pitfalls to Avoid
Even experienced developers make these mistakes:
- Skipping the backup before migration.
- Forgetting to replace URLs inside widgets or shortcodes.
- Using temporary (302) instead of permanent (301) redirects.
- Not notifying Google about the domain change.
- Leaving hardcoded references in theme files or custom templates.
Addressing these proactively can save hours of troubleshooting later.
Wrapping It Up
A successful domain migration in WordPress is more than just a technical procedure; it’s about preserving the digital identity you’ve built. If you know how to change the URL in WordPress properly, you don’t just fix links. You retain authority. You avoid confusing users. You signal to search engines that you’re still the same site, just dressed differently.
Don’t rush it. Test everything. And if the idea of tweaking databases or rewriting redirect rules makes you uncomfortable, that’s fine. Having the right partner behind your domain and hosting setup can make the transition seamless.
Looking to make your domain change smoother and smarter? With tools built for WordPress and a support team that knows migration inside and out, BigRock is a name you can rely on. Whether you’re starting fresh or shifting direction, they’ve got everything you need to move confidently.