Changing a WordPress URL incorrectly is one of the fastest ways to make a site completely inaccessible — to visitors, to search engines, and to yourself. Done in the right order, with the right tools, learning to change WordPress URL safely is a straightforward operation that takes 20 minutes. Done carelessly — changing one URL setting but not the other, or changing the URL without updating the database references — it produces redirect loops, broken images, inaccessible admin panels, and search ranking damage that can take days to recover from. I have handled URL changes in both scenarios, and the difference is entirely in understanding exactly what WordPress does with URL settings and following the correct sequence. This guide covers every method to change WordPress URL safely, from the standard admin route through to the database-level approach for when the admin panel is already broken because of an incorrect URL setting. You’ll find the complete rundown in our Complete Guide to WordPress How.
Before you start: Take a full backup of the site — database and files — before making any URL change. A URL change gone wrong can make the site completely inaccessible, and a backup taken before the change is the recovery path back. This is non-negotiable. Do not proceed without it.
Understanding the Two WordPress URLs Before Changing Anything
WordPress stores two distinct URL values that together determine how the site resolves. To change WordPress URL safely, you need to understand what each controls and why both matter — changing only one without the other is the source of most URL-change problems.
The WordPress Address (URL) — stored in the database as siteurl — is the URL of the WordPress installation itself. WordPress uses this value to construct URLs for admin pages, REST API endpoints, and internal WordPress requests. When you navigate to the WordPress admin, WordPress uses the siteurl to build the dashboard URL. The Site Address (URL) — stored in the database as home — is the URL where the site is publicly accessible. WordPress uses this value to construct front-end page URLs, the blog homepage URL, and canonical links in the HTML output.
In most WordPress installations, both values are identical — if the WordPress installation is at the domain root and the public site is at the same location, there is no reason for them to differ. They differ intentionally when WordPress is installed in a subdirectory (example.com/wordpress/) but the site is served from the root (example.com/) — a configuration where the siteurl includes the subdirectory but the home URL does not. To change WordPress URL safely, you need to update both values to their new correct values — if the domain has changed, both need to reflect the new domain. If only the siteurl is updated but home is not (or vice versa), WordPress generates a URL mismatch that typically produces a redirect loop or an inaccessible admin panel.
Change WordPress URL Safely Through the Admin Settings
The standard admin settings method to change WordPress URL safely is appropriate when: the current WordPress admin is accessible, and the new URL is reachable at its correct location (the domain has already been pointed to the new server if applicable, or you are changing from subdirectory to root on the same server).
- Log in to the WordPress admin panel
- Navigate to Settings → General
- In the WordPress Address (URL) field, update the URL to the new value — the complete URL including protocol and domain:
https://newdomain.com. No trailing slash. - In the Site Address (URL) field immediately below, update to the same new URL value (unless there is an intentional subdirectory configuration that needs to be preserved)
- Click Save Changes
- WordPress saves the new URL values and immediately redirects you to the login page using the new URL. This is expected and correct behaviour — you are now accessing WordPress at the new URL
- Log in at the new URL and verify the admin panel loads correctly
- Load the front end of the site at the new URL and verify the homepage loads without errors
- Proceed to the database search-and-replace step to update all hardcoded URL references stored throughout the database (covered in the next section)
The Settings → General method is the cleanest way to change WordPress URL safely precisely because WordPress handles the URL update atomically — both values are saved together and WordPress’s internal URL construction switches to the new values immediately. The redirect to the login page after saving is a reliable indicator that the setting saved correctly. If the redirect goes to the old URL rather than the new one, the save did not take effect — check whether a plugin or wp-config.php constant is overriding the database setting.
Change WordPress URL Safely via wp-config.php When Admin Is Inaccessible
If the WordPress admin is already inaccessible due to an incorrect URL setting — the most common situation being a URL that was changed to an incorrect value, producing a redirect loop or a login page that redirects back to itself — the wp-config.php method bypasses the admin entirely and forces WordPress to use specific URL values regardless of what the database contains.
Connect to your server via FTP or the hosting file manager and open wp-config.php. Add these two lines directly before the “That’s all, stop editing!” comment:
define( 'WP_HOME', 'https://correctdomain.com' ); define( 'WP_SITEURL', 'https://correctdomain.com' );
Replace https://correctdomain.com with the exact correct URL the site should use — including the correct protocol (http or https), with or without www to match the canonical version, and no trailing slash. Save the file and reload the site. WordPress reads these constants at startup and uses them instead of the database values — the URL mismatch causing the inaccessibility is overridden instantly.
After the admin panel is accessible again using these constants, go to Settings → General and update both URL fields to the correct values, then save. After the database values are correct, remove the WP_HOME and WP_SITEURL constants from wp-config.php — they are no longer needed and leaving them in place means database URL changes via the admin will have no effect, which can cause confusion later. The constants are a temporary override to regain access, not a permanent configuration method to change WordPress URL safely. Use the admin settings for the permanent change once access is restored.
Change WordPress URL Safely via phpMyAdmin — The Direct Database Method
The phpMyAdmin method to change WordPress URL safely is appropriate when both the admin panel and wp-config.php access are unavailable, or when you need to change the URL on a fresh database before WordPress has been configured. It directly edits the database rows that store the URL values, bypassing all WordPress application layers.
- Log in to cPanel and open phpMyAdmin
- Select your WordPress database from the left sidebar
- Click the
wp65_optionstable (using your actual table prefix) - Click the Search tab. Search for
option_namewith valuesiteurl. Click Go. - Click the Edit (pencil) icon on the row returned. Change the
option_valuefield to the new correct URL. Click Go to save. - Repeat the search for
option_namewith valuehome. Edit that row’soption_valueto the same new correct URL. Click Go to save. - Navigate to your site in a browser to confirm it loads at the new URL
The phpMyAdmin method is the most reliable way to change WordPress URL safely when every other access method has failed — it works regardless of WordPress’s application state because it operates directly on the database. The values written here are the same values that Settings → General updates, just written directly rather than through the WordPress interface. After the site is accessible again, proceed with the database search-and-replace to update all other stored URL references.
Update All Hardcoded URLs in the Database After Changing WordPress URL
Changing the siteurl and home values in wp_options is only the first step to change WordPress URL safely and completely. These two values control WordPress’s URL generation going forward, but they do not retroactively update the thousands of URLs already stored throughout the database — in post content, attachment metadata, widget settings, plugin option values, and custom fields. All of these stored references to the old URL remain, producing broken images, broken internal links, and incorrect metadata until a database-wide search-and-replace updates them.
The Better Search Replace plugin (free; WordPress Plugin Directory) is the safest tool for this database-wide update because it handles serialised PHP data correctly — WordPress and plugins often store settings as serialised PHP arrays, and a naive find-and-replace that does not account for serialisation corrupts these values. Install Better Search Replace, navigate to Tools → Better Search Replace, enter the old URL in the Search for field and the new URL in the Replace with field, select all database tables, and first run a Dry Run to see how many replacements will be made without actually making them. Confirm the count looks reasonable, then run the actual replacement.
WP-CLI provides the same functionality from the command line: wp search-replace 'https://olddomain.com' 'https://newdomain.com' --skip-columns=guid. The --skip-columns=guid flag preserves the GUID values that WordPress uses for feed item identification — changing these causes duplicate items to appear in RSS feeds for existing subscribers. This is the preferred method to change WordPress URL safely via search-and-replace on hosting environments with SSH access, as it handles very large databases more reliably than the plugin’s web-based interface.
After the URL Change — What to Fix and Verify
A completed URL change requires a systematic post-change verification to catch any remaining issues before declaring the process complete. Even after a successful search-and-replace, some components may reference the old URL in places not covered by the database operation.
- Permalinks regeneration: Navigate to Settings → Permalinks and click Save Changes — this regenerates the
.htaccessrewrite rules using the new URL, resolving any permalink structure issues - SSL/HTTPS verification: If the URL change included switching from HTTP to HTTPS, check for mixed content warnings in the browser console (F12 → Console). Mixed content means some resources are still loading over HTTP — run the Better Search Replace again changing all
http://domain.comtohttps://domain.comto catch any remaining HTTP references - Image and media verification: Load several pages with images and verify all images display correctly. A failed image search-and-replace leaves broken image placeholders on every post and page
- Plugin settings review: Check settings for plugins that store URLs explicitly in their own settings — Google Analytics integrations, contact form notification URLs, payment gateway webhook URLs, and CDN configurations all typically require manual URL updates that the database search-and-replace does not cover
- Cache purge: Clear all caches — WordPress caching plugin, object cache, CDN cache, and browser cache — to ensure visitors see the updated URLs rather than cached versions with old references
- 301 redirects: If the old domain or URL is still accessible, implement 301 redirects from every old URL to the new equivalent. For a full domain change, a root-level redirect in .htaccess handles this:
RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L] - Search Console update: Update the property in Google Search Console to the new URL, submit the updated sitemap, and monitor for crawl errors in the weeks following the change
Our guide on fixing the WordPress too many redirects error covers the redirect loop that is the most common consequence of an incorrectly handled URL change — the guide to reach for if the URL change produces a browser redirect loop. Our guide on fixing the WordPress mixed content error covers the HTTPS mixed content issues that appear when a URL change from HTTP to HTTPS leaves HTTP references in the database or theme files. The Kinsta WordPress URL change documentation covers managed host-specific URL change procedures — particularly relevant if the URL change is being done on managed WordPress hosting where some of the standard approaches work differently. Our guide on How to Change WordPress Admin Email Safely With a Proven Secure Method covers an adjacent issue.





