
TL;DR: Changing your domain name in WordPress requires updating your Site URL in Settings, editing wp-config.php, running a database search-replace for all old URLs, setting up 301 redirects in .htaccess, and waiting for DNS propagation. Done in the right order, you can complete a full domain migration in under two hours with minimal to no long-term SEO impact.
Last Updated: November 2026. Steps verified against WordPress 6.7 running on PHP 8.3.
How to Change Your Domain Name in WordPress (Without Losing SEO)
Try GigaPress AI Free →
Changing your domain name in WordPress is one of those tasks that sounds simple but can quietly break your site if you skip a step. Miss the database search-replace and you end up with hundreds of hard-coded old URLs scattered through post content, image paths, and plugin settings. Skip the 301 redirects and your old domain stops passing link equity to the new one, and Google treats the new domain as a brand-new site with zero authority.
This guide walks you through every step in the correct order: updating WordPress settings, editing wp-config.php, running the database search-replace with WP-CLI or phpMyAdmin, configuring 301 redirects in .htaccess, and understanding the DNS propagation timeline so you know exactly what to expect after go-live.
Before You Start: Essential Pre-Migration Checklist
A domain change touches almost every layer of your WordPress install. Take these precautions before you change a single setting.
- Full site backup. Export your database and download a complete copy of your wp-content folder. Store both off-server. If anything goes wrong, this is your escape hatch.
- Register and configure the new domain. Make sure you own the new domain and that it is pointed at the same hosting account as your current site, or at minimum that you have access to its DNS records.
- Note your current Site URL and WordPress URL. Go to Settings, then General, and write down both values exactly as they appear.
- Set up Google Search Console for the new domain. You will need an active GSC property for the new domain so you can submit a Change of Address request after migration.
- Put the site in maintenance mode. Brief downtime during the switch prevents visitors from hitting broken URLs mid-migration.
If you have never handled a migration before, it may be worth reading through how a solid WordPress hosting environment supports domain changes before you start, since some hosts provide built-in tools that simplify several of the steps below.
Step 1: Update the Site URL in WordPress Settings
The fastest way to update your domain in WordPress is through the admin dashboard. Log into your WordPress admin, navigate to Settings, then General. You will see two fields.
- WordPress Address (URL): The location of your WordPress core files.
- Site Address (URL): The public URL visitors use to reach your site.
Change both values from your old domain to your new domain. Keep the same protocol (https://) and do not add a trailing slash. Click Save Changes.
Important: as soon as you save, WordPress will redirect your admin session to the new domain. If DNS is not yet pointing to your server, you will lose access to the dashboard through the new URL. This is why many developers prefer to make this change via wp-config.php instead, as explained in Step 2.
Step 2: Update wp-config.php (The Safer Method for 2026)
Defining your URLs in wp-config.php overrides whatever is stored in the database, which means you can safely set the new domain before DNS resolves, and your site will still load correctly on the server side. This approach also prevents the lockout risk mentioned in Step 1.
Connect to your server via SFTP or SSH, open the wp-config.php file in the root of your WordPress install, and add these two lines directly above the line that reads /* That's all, stop editing! */:
define( 'WP_HOME', 'https://yournewdomain.com' );
define( 'WP_SITEURL', 'https://yournewdomain.com' );
Replace yournewdomain.com with your actual new domain. Save the file and re-upload it. These constants take precedence over the database values, so your WordPress install will now load under the new domain regardless of what is stored in the wp_options table.
Once the domain change is fully complete and confirmed working, you can remove these lines and let WordPress read the values from the database instead, or leave them in place as a permanent override.
Step 3: Run the Database Search-Replace (This Is the Critical Step)
Your WordPress database contains thousands of references to your old domain: in post content, image src attributes, widget data, theme customizer settings, and plugin option rows. Simply changing the Site URL does not update these. You must run a search-replace across the entire database to swap every instance of the old domain for the new one.
There are two reliable methods.
Method A: WP-CLI (Recommended)
WP-CLI is the command-line interface for WordPress. If your host provides SSH access, this is the fastest and most thorough method. It handles serialized data correctly, which phpMyAdmin’s simple find-and-replace cannot always do.
SSH into your server, navigate to your WordPress root directory, and run:
wp search-replace 'https://oldomain.com' 'https://yournewdomain.com' --all-tables --report-changed-only
The --all-tables flag ensures every table in the database is checked, not just the default WordPress tables. The --report-changed-only flag outputs a clean summary of which tables were modified and how many rows changed. Review this output carefully before you proceed.
If you want to do a dry run first, add the --dry-run flag to see what would change without actually writing anything to the database:
wp search-replace 'https://oldomain.com' 'https://yournewdomain.com' --all-tables --dry-run
Full WP-CLI documentation is available at WordPress Developer Resources.
Method B: phpMyAdmin
If your host does not offer SSH access, use phpMyAdmin through your hosting control panel. Log in, select your WordPress database, and click the SQL tab. Run the following queries one at a time, replacing the domain values with your own:
UPDATE wp_options SET option_value = replace(option_value, 'https://olddomain.com', 'https://yournewdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, 'https://olddomain.com', 'https://yournewdomain.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'https://olddomain.com', 'https://yournewdomain.com');
UPDATE wp_usermeta SET meta_value = replace(meta_value, 'https://olddomain.com', 'https://yournewdomain.com');
Note that phpMyAdmin’s SQL replace does not handle PHP serialized data correctly. If you have plugin options or theme settings stored as serialized arrays, those values may become corrupted. For complete safety, use WP-CLI or a plugin like Better Search Replace, which is serialization-aware.
Step 4: Configure 301 Redirects in .htaccess to Protect SEO
Even after the database is updated and your site loads on the new domain, your old domain will continue to receive traffic from bookmarks, inbound links, and cached search results for weeks or months. Without proper redirects, all of that traffic hits a dead end, and the link equity those inbound URLs carry does not transfer to your new domain.
A 301 redirect tells browsers and search engines that a resource has permanently moved to a new location. Google passes the vast majority of link equity through 301 redirects, which is why this step is non-negotiable if SEO matters to you.
Connect to your server via SFTP, open the .htaccess file in your WordPress root, and add the following block at the very top, above the standard WordPress rewrite rules:
#BEGIN Domain Redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?olddomain.com [NC]
RewriteRule ^(.*)$ https://yournewdomain.com/$1 [R=301,L]
</IfModule>
#END Domain Redirect
This rule catches requests to both the www and non-www versions of your old domain and redirects them to the equivalent URL on your new domain, preserving the full path and query string. The R=301 flag signals a permanent redirect; the L flag tells Apache to stop processing further rules once this one matches.
If your host uses Nginx instead of Apache, .htaccess rules will not work. You will need to add the equivalent redirect block in your Nginx server configuration or use your host’s redirect tool in the control panel.
After saving .htaccess, test the redirect by visiting a URL on your old domain in a browser and confirming it lands on the correct page on your new domain. Use a tool like RedirectCheck or your browser’s developer tools Network tab to verify the response code is exactly 301, not 302.
Step 5: Update SSL Certificates for the New Domain
Your new domain needs its own SSL certificate. Most modern WordPress hosting plans provision certificates automatically via Let’s Encrypt the moment a domain points to the server. Check your hosting control panel to confirm the certificate is active for the new domain before you send traffic to it.
If you encounter mixed content warnings after switching to the new domain, it usually means some URLs in your database were updated from HTTP to HTTPS on the old domain but are now being served with the wrong protocol on the new one. The fix is covered in detail in the guide on how to fix WordPress mixed content warnings.
Step 6: DNS Propagation Timeline — What to Expect in 2026
Once you update your domain’s DNS records to point to the new server (or confirm they already point to the same server), DNS propagation begins. This is the process by which the change spreads across DNS resolvers worldwide.
Typical propagation timelines in 2026:
| DNS Record Type | Typical Propagation Time | Notes |
|---|---|---|
| A Record (IPv4) | 15 minutes to 4 hours | Depends on old TTL setting |
| AAAA Record (IPv6) | 15 minutes to 4 hours | Same TTL behavior as A records |
| CNAME Record | Up to 24 hours | Longer due to chained resolution |
| NS Record (nameserver) | 24 to 48 hours | Slowest; involves registrar propagation |
If you lower your TTL (Time to Live) to 300 seconds (5 minutes) at least 24 hours before the migration, the old value expires quickly across all resolvers and your propagation window shrinks to under an hour in most cases. This is a best practice worth doing at every domain migration.
During propagation, some visitors will still see your old domain. This is normal. Keep your old domain and its redirects active for a minimum of 12 months. Many SEO professionals recommend keeping the old domain redirecting indefinitely as long as the registration cost is manageable.
Step 7: Post-Migration SEO Tasks to Protect Your Rankings
The technical migration is complete, but several SEO housekeeping tasks are required to minimize ranking disruption and help Google re-index your new domain as quickly as possible.
Submit a Change of Address in Google Search Console
Log into Google Search Console, select your old domain property, go to Settings, and use the Change of Address tool. This directly signals to Google that your site has permanently moved and speeds up the process of associating your existing ranking signals with the new domain. You must have the new domain verified in GSC before you can submit the request.
Update Your XML Sitemap and Resubmit
Your SEO plugin (Yoast SEO, Rank Math, or similar) will generate a sitemap automatically once your domain is updated. Submit the new sitemap URL to Google Search Console under Index, then Sitemaps. This helps Googlebot discover and crawl your URLs on the new domain quickly.
Update Google Analytics and Any Third-Party Integrations
Your GA4 data stream is tied to a specific domain. If you have a separate data stream configured for the old domain, add a new data stream for the new domain in your Google Analytics property. Also update any hardcoded domain references in your analytics setup. The guide on how to add Google Analytics to your WordPress site covers the current GA4 setup process if you need a refresher.
Audit Internal Links and Update High-Value Backlinks
Even with 301 redirects in place, internal links pointing to the old domain add an unnecessary redirect hop that slows page load time. Use a crawl tool like Screaming Frog to find any remaining internal links pointing to the old domain and update them directly in the WordPress editor. For external backlinks, reach out to the highest-authority sites linking to your old domain and ask them to update the link to the new domain directly.
Monitor Rankings and Crawl Errors for 90 Days
Expect some ranking fluctuation in the first two to six weeks. This is normal. Google is re-crawling and re-evaluating your content under the new domain. As long as your 301 redirects are in place, rankings typically return to or exceed their previous levels within 60 to 90 days. Watch GSC’s Coverage report for any new 404 errors that may indicate URLs the redirects are not catching. This is also a good time to review how you are tracking performance, since understanding keyword research for a new WordPress website can help you identify which pages need the most monitoring attention after migration.
Choosing the Right Hosting Environment for a Domain Migration
The quality of your hosting environment has a direct impact on how smooth a domain migration goes. Hosts that offer SSH access, easy SSL provisioning, and a one-click staging environment make every step in this guide easier and safer. If your current host makes it difficult to access wp-config.php, run WP-CLI commands, or manage DNS records, a migration is a natural opportunity to upgrade.
See the guide on how to choose the right WordPress hosting plan for your business for a detailed breakdown of what to look for. For higher-traffic or business-critical sites, the options covered in the managed WordPress hosting guide are worth reviewing since managed hosts typically handle SSL provisioning, DNS, and even URL replacement tooling as part of their migration assistance.
Want a Pro WordPress Site in Minutes?
GigaPress AI builds you a full WordPress site in about 15 minutes — AI handles layout, styling, content, and images. Free to design, only pay when you’re ready to go live. If you are launching on a fresh domain after a rebrand, GigaPress AI can have your new site ready before your DNS fully propagates.
Frequently Asked Questions
Can I change my domain name in WordPress without losing Google rankings?
Yes, you can change your domain name in WordPress without permanently losing rankings, but you must set up 301 redirects from every old URL to the new one and submit a Change of Address request in Google Search Console. Without these steps, Google treats the new domain as a brand-new site. With them, most sites recover to previous ranking levels within 60 to 90 days.
What is the difference between WP_HOME and WP_SITEURL in wp-config.php?
WP_SITEURL defines the location of your WordPress core files (the directory where WordPress is installed). WP_HOME defines the public address visitors use to access your site. In most standard installs where WordPress is in the root directory, both values are identical. If WordPress is installed in a subdirectory (for example, /wp/) but the site is served from the root, the two values will differ.
Why do I need to run a database search-replace when changing my domain?
WordPress stores your domain URL in dozens of database rows beyond the basic siteurl and home options. Post content, image attachment URLs, widget settings, theme customizer data, and many plugin option rows all contain hardcoded references to the old domain. If you only update the Site URL setting and skip the search-replace, visitors will encounter broken images, broken links, and mixed content errors. The database search-replace ensures every stored reference is updated to the new domain.
How long should I keep the old domain redirecting after migration?
Keep the old domain active with 301 redirects pointing to the new domain for a minimum of 12 months. Longer is better: external sites that link to your old domain may not update their links for years, and those links continue passing SEO value through the redirect as long as the domain is registered and the redirect is in place. The registration cost is usually a worthwhile ongoing expense.
Does WP-CLI handle serialized data correctly during a domain search-replace?
Yes. The wp search-replace command is serialization-aware and correctly recalculates the byte-length prefixes in PHP serialized strings after replacing the domain. This is a critical advantage over a raw SQL replace in phpMyAdmin, which can corrupt serialized data and break plugin or theme settings that depend on those values.



