HowTo

How to Change Your WordPress Site Address Without Breaking It

Changing your WordPress site address sounds like a one-field job: type the new URL, click save, done. Then the page reloads into an error, your dashboard disappears, and you’re locked out of your own site. It happens to a lot of site owners — and it’s completely avoidable.

This guide shows you when you actually need to change the site address, how to prepare, the safe ways to make the change, how to fix old links, and what to do if you end up in a redirect loop.

When you need to change the site address

WordPress stores two URLs in Settings → General:

  • WordPress Address (URL) — where the WordPress files live.
  • Site Address (URL) — the address visitors type to reach your site.

For most sites, both are the same. You’ll need to change them when you:

  • Move from a temporary or staging domain to your real domain.
  • Switch from http:// to https:// after installing SSL.
  • Rebrand to a new domain name.
  • Move between www and non-www versions.
  • Move WordPress out of a subfolder (like /wp/) to the root.

Backing up before you start

Never change your site address without a full backup. If something goes wrong, a backup turns a disaster into a five-minute restore.

  1. Back up the database — this is where the URLs are stored.
  2. Back up your files, especially wp-config.php and wp-content.
  3. Download the backup to your computer, not just to the server.
  4. Make sure you can reach your hosting panel and file manager, in case you get locked out of WordPress.

Need a backup tool? Compare options in Best Backup Plugins for WordPress Compared.

Changing the URL in Settings or wp-config

Method 1: Settings (simplest)

  1. Go to Settings → General.
  2. Update both the WordPress Address and the Site Address to the new URL — always change them together.
  3. Make sure the new domain already points to your hosting and SSL is active if you’re using https://.
  4. Click Save Changes. You’ll be logged out; log in again at the new address.

Method 2: wp-config.php (when you can’t reach the dashboard)

If you’re locked out, open wp-config.php in your hosting file manager and add these two lines above the line that says “That’s all, stop editing!”:

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

These override the database values, so you can log back in immediately. The fields in Settings will appear greyed out while these lines are present.

Method 3: phpMyAdmin — in the wp_options table, edit the siteurl and home rows. Use this only if you’re comfortable working in the database.

Fixing old links in the database

Changing the site address doesn’t update links inside your content. Images, internal links, and menus may still point to the old URL, which causes broken images and mixed-content warnings.

The fix is a search and replace across the database:

  • Use a plugin such as Better Search Replace, or WP-CLI: wp search-replace 'http://olddomain.com' 'https://newdomain.com'.
  • Always run a dry run first to see how many changes will be made.
  • Use a proper tool — never a plain text editor on an SQL file. WordPress stores some data in serialized form, and a naive replace can corrupt it.

If you changed domains, also set up 301 redirects from the old domain to the new one so visitors and search engines follow you, and update the domain in Google Search Console.

Troubleshooting redirect loops

“Too many redirects” is the most common problem after a URL change. Work through these checks:

  1. HTTP vs HTTPS mismatch: make sure both URLs use the same protocol and that SSL is really active on the domain. Read What Is SSL? How to Get HTTPS for Free if you’re unsure.
  2. www vs non-www: confirm your URLs match the version your host or CDN redirects to.
  3. Cloudflare SSL mode: “Flexible” mode often causes loops on HTTPS sites; switch to “Full” or “Full (strict).”
  4. Clear every cache: your caching plugin, server cache, CDN, and browser.
  5. Check .htaccess for old redirect rules that point back to the previous address.

Still stuck? Use the wp-config.php method above to force the correct URLs, then fix the rest from the dashboard.

Key takeaways

  • Back up the database and files before changing anything.
  • Update the WordPress Address and Site Address together.
  • Use wp-config.php to recover if you get locked out.
  • Run a proper search-replace to fix old URLs in your content.
  • Most redirect loops come from HTTP/HTTPS or www mismatches.
Z
zasma171

Writes for Hostreta about the topics covered in this article.

Comments (0)

Your email address will not be published. Required fields are marked *

Recent Comments

No comments to show.
Ad · AdSense
Ad space 300×250
Affiliate links
Tools we recommend
Protect Your Website with Automated Daily Backups
$2.09
Get it
the easiest way to manage all of your social media accounts
$29
Get it
Starter Website Get online, properly
$249
Get it
google workspace Business Starter
$3.75
Get it
Nord Vpn Cybersecurity. Built for Everyday Use
$8.99
Get it

We may earn a commission on purchases made through these links, at no extra cost to you.

Ad · AdSense
Ad space 300×600
Ad · AdSense
Ad space 300×600

$ top hosting picks

affiliate
★★★★★

NovaHost

$2.95/mo,renews at $9.95
  • Free SSL + domain, first year
  • 1-click WordPress install
  • 24/7 chat, sub-5-min response
get this deal →
affiliate link · we may earn a commission
★★★★★

CloudRoot

$4.50/mo,renews at $12.95
  • Built-in CDN + caching
  • Daily backups, 30-day retention
  • Staging environments included
get this deal →
affiliate link · we may earn a commission
★★★★★

ByteForge

$3.75/mo,renews at $10.95
  • NVMe storage on every plan
  • Unlimited bandwidth
  • Free migration from your old host
get this deal →
affiliate link · we may earn a commission

Never miss a new article

Join thousands of developers and builders getting a weekly digest of the best tech articles.