Hosting WordPress Spanish version

Support article

How to Change the WordPress URL Correctly

Switch WordPress from HTTP to HTTPS or to a different domain without losing access, links, images, or search rankings.

Published: 30/06/2026 Updated: 12/07/2026

Introduction

Changing the WordPress URL can be necessary when turning on HTTPS, replacing a domain, moving the site to a subfolder, or fixing an address that was set up incorrectly.

The change isn’t just about editing two fields — you also need to check internal links, images, serialized content, redirects, caching, the SSL certificate, and the server configuration. This guide is for standalone installs; on WordPress Multisite addresses are managed differently.

Take a full backup of the files and database before changing addresses (see WordPress backup and restore).

The difference between WordPress’s two URLs

Under Settings > General you’ll find the WordPress Address (where the core files live) and the Site Address (the public address visitors use). On a normal install these are usually the same. They must include https:// or http:// and shouldn’t have a trailing slash. Don’t change them “to test” without having access to the hosting panel — an incorrect value can lock you out of WordPress.

Case 1: switching from HTTP to HTTPS

Before touching WordPress, the SSL certificate must be installed and valid for the domain and, if applicable, for www (see how to activate SSL in cPanel).

Step 1: confirm https://yourdomain.com loads with no certificate warnings.

Step 2: back up the files, database, and .htaccess.

Step 3: under Settings > General, change both addresses from http:// to https:// and click Save Changes.

Step 4: replace old internal links. Even though the main URLs now use HTTPS, references may remain in content, images, widgets, plugin options, or custom CSS. The safest approach is WP-CLI, which handles serialized data correctly:

wp search-replace 'http://yourdomain.com' 'https://yourdomain.com' --all-tables-with-prefix --dry-run

Review the results and, if correct, repeat without --dry-run. Don’t do a direct find-and-replace with a text editor on an SQL export — you could damage serialized options and widgets.

Step 5: redirect HTTP to HTTPS. On Apache, before WordPress’s own rules:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

On Nginx, the redirect is configured at the server-block level, not in .htaccess. Avoid adding several redirects for the same thing, since they can create loops.

Step 6: check for mixed content (images, stylesheets, scripts, or fonts loaded over HTTP on an HTTPS page) and clear every cache.

Case 2: switching WordPress to a different domain

Step 1: prepare the new domain: add it to the hosting, configure its DNS, point it to the right folder, and activate the SSL certificate.

Step 2: take a full backup, including related email if applicable.

Step 3: change home and siteurl under Settings > General once both addresses are already reachable.

Step 4: replace the references in the database with WP-CLI:

wp search-replace 'https://old-domain.com' 'https://new-domain.com' --all-tables-with-prefix --dry-run

If HTTP or www variants existed too, handle them separately.

Step 5: set up 301 redirects from the old domain. On Apache:

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

Adapt the rule to your setup. Redirects help users and search engines find the new content, but they don’t guarantee there won’t be temporary ranking fluctuations on their own.

How to regain access if you changed the URL incorrectly

Method 1 (wp-config.php):

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

These constants force the values and lock editing from Settings > General. You can remove them once you’ve fixed the database.

Method 2 (phpMyAdmin): open the database, find the wp_options table (the prefix may not be wp_), locate the siteurl and home options, and fix their values. Back up before editing.

Method 3 (WP-CLI):

wp option update home 'https://yourdomain.com'
wp option update siteurl 'https://yourdomain.com'

Special case: WordPress in a subfolder

It’s possible to keep the files at https://yourdomain.com/wordpress while showing the site at https://yourdomain.com. In that case, the WordPress Address would be https://yourdomain.com/wordpress and the Site Address, https://yourdomain.com. This setup requires moving or copying index.php and adjusting the loading path following WordPress’s specific procedure — changing one field isn’t enough.

Checks after the change

Check the homepage and internal pages, access to /wp-admin, images and downloadable files, forms and email, the cart and checkout if there’s a store, login and password recovery, the REST API and cron tasks, the sitemap and robots.txt, canonical tags and SEO metadata, external integrations, and the browser, plugin, server, and CDN caches.

Go to Settings > Permalinks and click Save Changes to regenerate the rules if you see 404 errors (see configuring WordPress permalinks).

Common issues

Redirect loop

This usually happens when WordPress, .htaccess, the panel, a CDN, and a plugin all try to force HTTPS at the same time. Keep a single, clear logic and check whether there’s a reverse proxy involved.

The admin area redirects to the old domain

Check WP_HOME, WP_SITEURL, the home and siteurl options, the cache, and cookies.

Images still point to the old domain

Run a replacement compatible with serialized data and check CSS, widgets, and the page builder’s options.

404 errors show up

Save the permalinks again and check .htaccess or the Nginx rules.

Frequently asked questions

Do I need to install SSL before switching to HTTPS?

Yes. The certificate must be active before you change WordPress’s addresses.

Will I lose search rankings by changing domains?

There can be temporary fluctuations. Keep 301 redirects in place, preserve the URL structure when possible, and update your search engine tools.

Can I change the URL only from phpMyAdmin?

You can fix home and siteurl, but a complete change also requires reviewing internal links, redirects, and external services.

Is installing an SSL plugin enough?

Not always. The plugin can help with redirects or mixed content, but the certificate and server configuration still need to be correct.

Conclusion

To change the WordPress URL safely, prepare the domain and certificate first, back up, update the addresses, replace internal references with a tool that handles serialized data, and set up the redirects.

If the site is critical or has a store, memberships, or many integrations, make the change during a controlled window or ask for technical support to reduce the risk of downtime.