Contact

Web Design

Changing a WordPress Domain or Moving to HTTPS: Replacing URLs in the Database

To change a WordPress domain or move to HTTPS, you prepare SSL and a backup, update the site addresses, replace URLs in the database with a serialization-safe tool, then set up 301 redirects and Search Console. This guide walks through every step in order.

Illustration of a WordPress site switching to a new domain and a secure HTTPS connection
Contents

This guide is for businesses that are rebranding or moving from a country domain to a .com, site owners who have run on plain http for years and want HTTPS at last, and agency teams doing either job for clients. Both changes look like a single setting from the outside, but behind them sit thousands of old URLs in the database, links hardcoded in theme files and addresses that search engines have known for years. Below we explain what to do in each case, how to replace URLs safely and how to protect your search traffic.

What's the difference between changing the domain and moving to HTTPS?

Changing the domain means replacing the main name in your address (examplecafe.co.uk becomes examplecafe.com); moving to HTTPS means keeping the name and only switching the protocol from http:// to https://. Both require replacing URLs in the database and 301 redirects. What differs is what you tell search engines and which outside services are affected.

A domain name change alters your brand's identity online: email addresses, social profiles, ad accounts and every site linking to you are affected. An HTTPS move is narrower; to Google it is the same site switching to its secure version. Many projects do both at once, which is the most demanding scenario.

2x2 matrix showing four switch scenarios by whether the domain and the protocol change
Knowing what changes tells you which steps you need.

If only the protocol changes

  • Replace http://yourdomain.com with https://yourdomain.com in the database.
  • Redirect every http request to https with a 301.
  • Don't use the Change of Address tool in Search Console; Google states it isn't meant for protocol changes.

If the domain changes too

  • Replace the old address in every form (http, https, with and without www) with the new one.
  • Redirect every URL on the old domain to its equivalent on the new domain, page by page.
  • Add the new property in Search Console and run the Change of Address tool from the old one.
  • Update email, analytics, payments and other third-party services.

How do you prepare for the switch?

The first rule is not to touch WordPress settings until the new address loads cleanly in a browser. Get the order wrong and you lock yourself out of the dashboard.

SSL certificate first

An SSL/TLS certificate encrypts the connection between browser and server and confirms who controls the domain. Most hosts install free certificates such as Let's Encrypt with one click from the control panel. If the domain is changing, make sure the certificate covers the new domain (and its www version if you'll use it); if only the protocol is changing, make sure https://yourdomain.com opens without a warning. For a domain change, also check that the new name's DNS records point to your server.

Backup and timing

  • Take a full backup of files and database; it is your rollback plan.
  • Pick your lowest-traffic hour and temporarily switch off your caching plugin.
  • Export a list of old URLs: your sitemap, your top pages in Search Console and your analytics reports are the reference for checking redirects later.
  • If the server is changing too, finish the move first; the steps are in our guide to migrating WordPress to a new host.

How do you change WordPress Address and Site Address?

WordPress knows its own address through two settings under Settings > General: WordPress Address (URL) is where the core files live, and Site Address (URL) is the address visitors use. On most installs they're identical. In the database they are the siteurl and home rows in the options table.

The moment you save new values there, your session moves to the new address, and if that address doesn't work yet you can't get back into the dashboard. In that case, or if you'd rather pin the values from the start, add these two lines to wp-config.php:

define( 'WP_HOME', 'https://examplecafe.com' );

define( 'WP_SITEURL', 'https://examplecafe.com' );

These constants override the database values and grey out the two fields under Settings > General. With SSH you can do the same with wp option update home 'https://examplecafe.com' and wp option update siteurl 'https://examplecafe.com'. Keep in mind that these settings only change the site's own address; image links in content, menus and page builder data still point to the old one.

Since WordPress 5.7, Tools > Site Health can offer to switch the site to HTTPS when your server supports it. That option updates the address settings and rewrites old URLs in content as pages are displayed; to clean the database permanently, we still recommend the method in the next section.

How do you replace URLs in the database?

The safe way to replace URLs in the database is to use a tool that understands PHP serialized data, run a dry run first, review the results and only then apply the change. There are three common methods, and the right one depends on your access.

Methods for replacing URLs in the WordPress database
MethodSerialized dataDry runWhen it fits
Search-and-replace plugin (e.g. Better Search Replace)PreservedYesWhen you only have dashboard access
WP-CLI wp search-replacePreservedWith --dry-runWith SSH access; fastest on large sites
SQL REPLACE in phpMyAdminBrokenNoNot recommended, except on a single column with no serialized data
Diagram of the six steps for changing a WordPress domain or moving to HTTPS
Order matters: certificate and backup come before settings.

Using a plugin

Plugins such as Better Search Replace ask for the text to find and the replacement, let you pick tables and show in a dry run how many rows would change. Details vary between versions, so check the current description before you use one. Deactivating the search-and-replace plugin once you're finished is a good habit.

Using WP-CLI

The wp search-replace command unpacks serialized values, replaces inside them and recalculates string lengths. Say you're moving a café's site from http://www.examplecafe.co.uk to https://examplecafe.com:

  1. Dry run: wp search-replace 'http://www.examplecafe.co.uk' 'https://examplecafe.com' --dry-run
  2. Review the table counts; if a table you didn't expect shows lots of matches, find out why.
  3. Apply: run the same command without --dry-run, adding --skip-columns=guid if needed. On a live site GUIDs act as identifiers for feeds, which is why many guides leave that column alone.
  4. Other forms: run separately for the old address without www and with https, then for the JSON-escaped form (http:\/\/www.examplecafe.co.uk).
  5. Check: search for leftovers with wp db search 'examplecafe.co.uk'.

If you're only moving to HTTPS, search for http://examplecafe.com and replace it with https://examplecafe.com. Don't replace bare http:// with https://; that also rewrites your links to other sites and breaks the ones that don't support HTTPS.

Why does manual SQL break things?

Serialized data stores the length of every string in front of it: s:28:"http://www.examplecafe.co.uk"; is a 28-character string. When a plain REPLACE turns it into https://examplecafe.com, the string drops to 23 characters but the 28 stays. PHP can't read the value, and theme options, widgets or plugin settings quietly fall back to defaults. We walk through more examples of the same problem in our guide to moving WordPress from localhost to a live server.

How do you do it with Doruva Migrate's Find & Replace?

The Find & Replace tool in Doruva Migrate is a serialization-safe search-and-replace tool you can use outside migrations, too. If you're staying on the same server while changing the domain or moving to HTTPS, you can do the whole replacement from this screen.

Doruva Migrate Find & Replace: Smart URL & path mode on, dry run result with matches per table and column
Find & Replace: see how many changes each table will get with a dry run, then apply.
  1. Enter the pairs: type the old and new address; use "Add another pair" for a second pair if needed, such as an old and new server path.
  2. Keep Smart URL & path mode on: for URLs it also replaces the http/https, protocol-relative //, www, JSON-escaped and URL-encoded variants; for paths it covers both slash styles. You don't need a separate run for each form.
  3. Run a dry run: the result shows how many matches in how many rows across how many tables would be replaced, with counts per table and column. "Replace now" only becomes available after a dry run with the same settings.
  4. Apply: serialized PHP data is rewritten with correct string lengths; values that can't be processed safely are left untouched and counted as skipped.

If the domain change comes with a server move, the plugin's export and import flow adapts URLs and paths automatically anyway. We recommend taking a backup from the plugin's Backups screen before you change anything. The plugin is free and coming soon to WordPress.org; features change between versions, so check the current list on the product page and on the Doruva WordPress plugins page.

How do you fix mixed content and URLs outside the database?

Once the database is clean, the old URLs that remain usually sit in theme files, CSS, CDN settings and outside services. After an HTTPS move they show up as mixed content warnings; after a domain change, as requests still going to the old domain.

What is mixed content?

Mixed content means a page loaded over HTTPS still pulls some resources, such as images, scripts or stylesheets, over plain http. Browsers block insecure scripts and styles; for images they show a warning or try to upgrade the request to https. The result is a missing padlock, menus that don't work or fonts that never load. The fastest way to find the culprits is to open the page and look at the console in your browser's developer tools, where each mixed content request is listed with its URL.

Hardcoded URLs: themes, CSS and CDN

  • Theme files: logo, font or script links written with a full URL in header.php, footer.php or functions.php. Replacing them with functions such as home_url() and get_theme_file_uri() fixes them for good.
  • CSS files: full URLs such as background-image: url(http://...); switch to relative paths or https.
  • Customizer and Additional CSS: Additional CSS and theme options under Appearance > Customize live in the database but are easy to overlook.
  • CDN and caching: update the CDN origin, the CDN hostname in your caching plugin and any image optimisation service, then purge the cache.
  • Server files: .htaccess, the Sitemap: line in robots.txt and constants in wp-config.php.

Email and third-party services

A domain change affects everything tied to the domain, not just the site. If your email moves to the new domain too, set up MX, SPF and DKIM records in DNS for the new domain and keep the old mailboxes running for a while. When you change the administration email address under Settings > General, WordPress sends a confirmation message to the new address; also update the sender and recipient addresses in your form plugins and your SMTP settings.

Checklist of places outside the database to update when a WordPress domain changes
Even after the database is clean, these places can still point to the old address.

301 redirects and SEO: how do you tell Google about the move?

Protecting search traffic starts with sending every URL on the old address to its equivalent on the new one with a permanent, server-level 301 redirect. Each page should go to its own counterpart, not all to the home page.

Server-level redirects

On Apache, these rules in the .htaccess file at the old domain's root are enough:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?examplecafe\.co\.uk$ [NC]

RewriteRule ^(.*)$ https://examplecafe.com/$1 [R=301,L]

For an HTTPS-only move, the condition becomes RewriteCond %{HTTPS} off and the target https://%{HTTP_HOST}/$1. On Nginx, return 301 https://examplecafe.com$request_uri; does the same job. Server-level redirects run before WordPress loads, so they're faster and keep working even if a plugin is deactivated. We cover redirect maps and avoiding chains in depth in our guide to 301 redirects during a redesign.

Search Console, sitemap and canonicals

Google describes site moves with URL changes step by step in its Search Central documentation and recommends keeping redirects in place for as long as possible, generally at least one year. In practice:

  • Add the new address as a property in Search Console; if you use a Domain property, a protocol switch doesn't need a new one.
  • If the domain changed, run the Change of Address tool from the old property's settings; it checks that the 301 redirects from the old address work.
  • Submit the new sitemap to the new property; we explain how sitemaps are generated in our WordPress XML sitemap guide.
  • Check that canonical tags, the logo and URL fields in your structured data, and your Open Graph tags all show the new address.
SEO safety table: what to check after the switch
CheckWhy it mattersHow to verify
Page-level 301sEach old page passes its value to its counterpartOpen your top old URLs one by one; each should land on the right page in one hop
No redirect chainsChains like http → www → https slow crawling downConfirm old http and www URLs reach the final address with a single 301
Canonical tagsA wrong canonical tells Google to prefer the old URLCheck the rel="canonical" value in the page source
SitemapHelps Google discover the new URLs fasterIt lists only new URLs and Search Console reads it
robots.txtA wrong rule can block the new site from crawlingOpen it on the new domain and read the Sitemap line and rules
Internal linksEvery internal link passing through a redirect is wasted workSearch the database again for the old address
Change of Address toolTells Google directly about a domain changeDomain changes only; run it from the old property
Timeline of checks after a domain or HTTPS switch, from switch day to one year later
The switch takes a day; following it up takes months.

Common mistakes

Most problems with domain and HTTPS switches come from doing steps in the wrong order or leaving something out. Picture a furniture shop moving from a .co.uk to a .com: the site opens, but campaign pages land on the home page, order confirmations stop arriving after payment, and search traffic takes weeks to recover. Each of those outcomes traces back to one of these mistakes.

  • Changing settings before SSL works: the new address won't load and you lose dashboard access. Certificate first, settings second.
  • A plain REPLACE in phpMyAdmin: it breaks serialized settings, and theme options and widgets reset.
  • Redirecting everything to the home page: Google often treats these like soft 404s; each page should go to its own counterpart.
  • Removing redirects too early: letting the old domain expire or deleting the rules after a few months throws away the value of old links.
  • Forgetting payment and webhook URLs: payment gateways, CRMs and automation tools keep sending notifications to the old address.
  • Redirect loops behind a reverse proxy or CDN: if SSL ends at the CDN and traffic reaches the server over http, WordPress can loop forever. Turn on end-to-end encryption at the CDN or make sure the server detects HTTPS correctly.

Summary and next steps

A domain change and an HTTPS move follow the same logic: certificate and backup first, then the WordPress addresses, then a serialization-safe database replacement that starts with a dry run, and finally server-level 301 redirects and Search Console. Finish the URLs outside the database, email and third-party services with a checklist and the switch is done without putting your traffic at risk. To confirm the result from the outside, scan your new address with our free SEO checker.

If you're planning the switch alongside a redesign or a server move, we can handle the whole process as part of our web design services. Tell us about your domain, your current setup and your timeline, and we'll map out the move together.

Frequently Asked Questions

Will moving to HTTPS hurt my Google rankings?

With page-level 301 redirects, correct canonical tags and an up-to-date sitemap, Google gradually replaces the old URLs with the new ones. Short-term fluctuation can happen during the switch; keeping the redirects in place for a long time matters.

I changed the address in Settings > General and can't log in. What now?

Add WP_HOME and WP_SITEURL with the correct address to wp-config.php, or fix the home and siteurl values in the options table through phpMyAdmin. Once both values are right, the dashboard is reachable again.

How long should I keep the old domain?

Google recommends keeping redirects for as long as possible, generally at least one year. Because other sites may still link to the old address, renewing the old domain for longer is usually the safest choice.

What's the difference between Better Search Replace and wp search-replace?

Both replace text while preserving serialized data and both offer a dry run. The plugin works from the dashboard; the WP-CLI command needs SSH but is faster on large databases and can be scripted.

How do I find the source of a mixed content warning?

Open the page and check the console in your browser's developer tools; every file loaded over http is listed with its URL. If the URL is in the database, fix it with search and replace; if it's in a theme or CSS file, edit that file.

Let’s apply this to your project.

Let’s look together at how the approach in this article applies to your own website, search visibility or digital systems.