# How to Change Your WordPress URL Without Breaking Your Site

> Source: https://mykavo.app/blog/how-to-change-wordpress-url  
> Author: Dakshesh  
> Published: 2026-11-28  
> Updated: 2026-11-28  
> Publisher: MyKavo (https://mykavo.app)  

## Summary

To change your WordPress URL, back up your site, then update the WordPress Address and Site Address in Settings > General, or set WP_HOME and WP_SITEURL in wp-config.php if you're locked out. Next, replace the old URL across the database with WP-CLI search-replace, add 301 redirects, and update Google Search Console.

## Key takeaways

- Back up and make sure the new address works before changing any setting.
- WordPress Address is where core files live; Site Address is what visitors use.
- wp-config.php constants override the database and fix most lockouts.
- Settings alone don't update saved links, so run a serialization-safe search-replace.
- 301 redirects and Search Console's Change of Address protect your rankings.

To change your WordPress URL, go to **Settings > General**, update the **WordPress Address (URL)** and **Site Address (URL)**, and save. That changes the address WordPress uses, but on its own it doesn't update links already saved in your posts, redirect old URLs or tell Google about the move. A clean URL change also needs a search-and-replace on the database and 301 redirects from the old address.

This guide covers every way to change the site address: the Settings screen, wp-config.php, a functions.php fallback for when you're locked out, and WP-CLI search-replace for moving from HTTP to HTTPS or to a new domain. It finishes with redirects, Search Console's Change of Address tool, and a checklist for after the switch.

> **Changing your site address?** The free [MyKavo WordPress plugin](https://mykavo.app/wordpress-plugin) checks your pages after every update and shows exactly what changed, from redirects to canonicals. [Start monitoring free](https://mykavo.app/signup).

## Quick answer: how to change your WordPress URL

1. **Back up your files and database** before touching anything.
2. **Make sure the new address works first:** the domain points to your server and an SSL certificate is active if you're moving to HTTPS.
3. **Update the two URLs** in Settings > General, or set `WP_HOME` and `WP_SITEURL` in wp-config.php if you can't reach wp-admin.
4. **Replace the old URL in the database** with `wp search-replace` or a search-and-replace plugin, running a dry run first.
5. **Add 301 redirects** from every old URL to its new equivalent.
6. **Tell Google:** add the new site to Search Console, submit your sitemap, and use the Change of Address tool if you moved to a new domain.
7. **Check key pages, forms and logins**, then clear all caches.

## Before you start: back up and prepare

Changing the site address is one of the few WordPress settings that can lock you out instantly. If you type a wrong URL and save, the next page load goes to an address that doesn't work.

- **Take a full backup** of files and database. Our [WordPress backup guide](https://mykavo.app/blog/wordpress-backup) covers plugin, host and manual options. With WP-CLI, `wp db export` creates a database file in seconds.
- **Point the new domain at your server** (DNS) and add it to your hosting account before changing WordPress.
- **Install an SSL certificate** for the new address if it uses HTTPS.
- **Know how to reach your files** over FTP, SFTP or your host's file manager, in case you need the fallback methods below.

If you're also moving to a new host, read our [website migration](https://mykavo.app/blog/website-migration) guide first, because the order of steps changes.

## WordPress Address vs Site Address

Settings > General has two URL fields, and they do different jobs:

| Field | Option name in the database | What it controls |
|-|-|-|
| **WordPress Address (URL)** | `siteurl` | Where WordPress core files live, including wp-admin and wp-login.php |
| **Site Address (URL)** | `home` | The address visitors type to reach your site |

**On most sites, both are identical**, such as `https://example.com`. They only differ when WordPress is installed in a subfolder (for example `https://example.com/wp`) but the site is served from the root domain.

## Method 1: Change the URL in Settings > General

Use this when you can log in and the new address already works.

1. Go to **Settings > General**.
2. Change **WordPress Address (URL)** and **Site Address (URL)** to the new address, such as `https://example.com`.
3. Don't add a trailing slash.
4. Click **Save Changes**.
5. WordPress logs you out. Log in again at the new address, such as `https://example.com/wp-admin`.

**If the fields are greyed out**, the URLs are set in wp-config.php (Method 2), and you'll need to change them there.

## Method 2: Set WP_HOME and WP_SITEURL in wp-config.php

Defining the URLs in wp-config.php overrides the database values. It's the quickest fix if you're locked out because of a wrong URL.

1. Open `wp-config.php` in your site's root folder over FTP or your host's file manager.
2. Add these lines above `/* That's all, stop editing! Happy publishing. */`:

```php
define( 'WP_HOME', 'https://example.com' );
define( 'WP_SITEURL', 'https://example.com' );
```

3. Save the file and load the site.

While these constants are set, the two fields in Settings > General are greyed out. You can leave them in place permanently, which also stops anyone changing the URLs from wp-admin. If you remove them later, the database values apply again, so make sure those are correct first.

## Method 3: The functions.php fallback

If you can't use wp-config.php, WordPress's documentation describes a one-time fix using your active theme's `functions.php`. It writes the new values to the database.

1. Connect over FTP and open `wp-content/themes/your-active-theme/functions.php`.
2. Add these lines right after the opening `<?php` line:

```php
update_option( 'siteurl', 'https://example.com' );
update_option( 'home', 'https://example.com' );
```

3. Load the login page or front end a couple of times.
4. **Remove the lines again.** They run on every page load while they're there.

If you're unsure which theme is active, check the `template` and `stylesheet` rows in the `wp_options` table, or use Method 2 instead.

## Method 4: WP-CLI search-replace (HTTP to HTTPS or a new domain)

Changing the two settings doesn't touch the URLs saved inside your content: image paths, internal links, menu items, widget settings and page builder data all still point at the old address. That's what causes [mixed content](https://mykavo.app/blog/wordpress-mixed-content) warnings after an HTTPS switch and broken images after a domain move.

[WP-CLI's search-replace](https://developer.wordpress.org/cli/commands/search-replace/) fixes this safely. **It handles serialized data**, which a plain SQL find-and-replace would corrupt.

```bash
# 1. Export a backup of the database first
wp db export before-url-change.sql

# 2. Dry run: shows what would change without changing anything
wp search-replace 'http://example.com' 'https://example.com' \
  --skip-columns=guid --dry-run

# 3. Run it for real
wp search-replace 'http://example.com' 'https://example.com' \
  --skip-columns=guid

# 4. Flush caches and rewrite rules
wp cache flush
wp rewrite flush
```

For a domain move, replace the old domain with the new one:

```bash
wp search-replace 'https://old-domain.com' 'https://new-domain.com' \
  --skip-columns=guid --dry-run
```

A few tips:

- **Include the protocol** (`https://`) in both strings so you don't change unrelated text, such as an email address on the old domain.
- **Run separate passes** if your content mixes `www` and non-www versions.
- **`--skip-columns=guid`** leaves post GUIDs alone; WordPress uses them as permanent identifiers, for example in feeds.
- **Custom tables:** by default the command searches tables registered with WordPress. Add `--all-tables-with-prefix` to include plugin tables that use your prefix.
- **Multisite** needs extra care: add `--network` or `--url=` and update the domain values for each site. Test on a copy first.

**No SSH?** Plugins such as Better Search Replace do the same job from wp-admin and also handle serialized data. Elementor also has **Elementor > Tools > Replace URL** for its own data.

## Step 5: Set up 301 redirects

Without redirects, every old link, bookmark and Google result leads to an error, and the old URLs' ranking signals aren't passed to the new ones. Use **301 (permanent) redirects**, not 302s. Our guide to [301 vs 302 redirects](https://mykavo.app/blog/301-vs-302-redirect) explains why.

### Force HTTPS (Apache .htaccess)

Add this above the `# BEGIN WordPress` block in `.htaccess`:

```apache
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
```

### Redirect an old domain to a new one (Apache)

Keep the old domain pointed at a server with this in its `.htaccess`:

```apache
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?old-domain\.com$ [NC]
RewriteRule ^(.*)$ https://new-domain.com/$1 [R=301,L]
```

### Nginx

```nginx
server {
    listen 80;
    listen 443 ssl;
    server_name old-domain.com www.old-domain.com;
    # ssl_certificate lines for the old domain go here
    return 301 https://new-domain.com$request_uri;
}
```

**Redirect page to page, not everything to the homepage.** Each old URL should go to its exact equivalent. Many hosts and Cloudflare also offer redirect rules in their dashboards. For page-level redirects inside WordPress, see [how to redirect a page in WordPress](https://mykavo.app/blog/how-to-redirect-a-page-in-wordpress).

Test a sample of old URLs with the free [redirect chain checker](https://mykavo.app/tools/redirect-chain-checker). Each should reach the new page in **one 301 hop**, not a chain. If the browser shows "too many redirects", see our guide to [ERR_TOO_MANY_REDIRECTS](https://mykavo.app/blog/err-too-many-redirects).

## Step 6: Tell Google about the change

1. **Add and verify the new site in Google Search Console.** A Domain property covers all protocols and subdomains.
2. **Submit your XML sitemap** for the new address.
3. **For a new domain, use the Change of Address tool.** In the old property, go to **Settings > Change of address**, pick the new property and submit. Google checks that you own both sites and that a few pages return 301 redirects.
4. **Don't use Change of Address for HTTP to HTTPS** or for www vs non-www changes. Google's documentation says to rely on redirects for those.
5. **Keep redirects in place long term.** Google's site move guidance recommends keeping them for at least a year, and longer is safer.

Also update the URL everywhere else it appears: Google Analytics data stream settings, Google Business Profile, social profiles, email signatures, ad campaigns and any CDN or firewall settings.

## After-change checklist

| Check | Why |
|-|-|
| Log in at the new /wp-admin | Confirms siteurl is correct |
| Browse key pages in a private window | Catches cached or broken pages |
| Look for mixed content warnings | Leftover http:// assets |
| Test contact forms and checkout | Plugins sometimes store full URLs |
| Check images and media | Old paths left in content |
| Test old URLs redirect in one hop | Preserves traffic and rankings |
| Check canonical tags point to the new domain | Wrong canonicals confuse Google |
| Clear plugin, host and CDN caches | Stale pages show the old URL |
| Update sitemap in Search Console | Speeds up recrawling |

## How to catch URL change problems automatically

A URL change touches almost every page, and the problems are rarely visible from wp-admin: a canonical still pointing at the old domain, a redirect that turned into a chain, an analytics script that stopped loading, a page that now returns a 404.

MyKavo monitors the pages you pick and alerts you when **HTTP status, redirects, canonical, title, meta description, robots meta, scripts or broken internal links** change, with before-and-after proof and a severity. It also checks each site is up every 5 minutes and warns before your SSL certificate expires. Once the move is done and verified, approve the changes as the new baseline. The free [MyKavo WordPress plugin](https://mykavo.app/wordpress-plugin) keeps checking your pages after every plugin, theme and core update.

## Frequently asked questions

### How do I change my WordPress site URL?

Go to Settings > General, update the WordPress Address and Site Address, and save. Then replace the old URL in your database with WP-CLI search-replace or a search-and-replace plugin, add 301 redirects, and update Google Search Console.

### What is the difference between WordPress Address and Site Address?

WordPress Address (siteurl) is where WordPress core files and wp-admin live. Site Address (home) is the URL visitors use. They're usually the same unless WordPress is installed in a subfolder.

### How do I change the WordPress URL if I'm locked out?

Add define('WP_HOME', 'https://example.com') and define('WP_SITEURL', 'https://example.com') to wp-config.php over FTP, or with SSH run wp option update home and wp option update siteurl with the correct address.

### Why are the WordPress Address fields greyed out?

The URLs are defined in wp-config.php with the WP_HOME and WP_SITEURL constants. Change them in wp-config.php, or remove the constants so the Settings fields become editable again.

### Will changing my WordPress URL hurt SEO?

It can cause a temporary dip, but 301 redirects from every old URL to its new equivalent pass most signals across. Keep redirects in place long term, update canonicals and sitemaps, and use Search Console's Change of Address tool for domain moves.

### Do I need to update links in my posts after changing the URL?

Yes. Settings > General doesn't change URLs saved in content, menus or widgets. Run wp search-replace or a plugin such as Better Search Replace to update them, after a backup and a dry run.

## The bottom line

Changing a WordPress URL is more than editing two fields. Back up first, make sure the new address works, update the URLs in Settings or wp-config.php, replace the old address throughout the database with a serialization-safe tool, and redirect every old URL with a 301. Then tell Google, check your key pages, and keep watching them for the weeks after the move.

**Make sure nothing broke in the move.** [Start monitoring your site free with MyKavo](https://mykavo.app/signup) and install the free [MyKavo WordPress plugin](https://mykavo.app/wordpress-plugin), no card needed.
