How to Safely Change Your WordPress Site URLs (Step-by-Step Guide)

Are you looking to change your WordPress site‘s URLs? Whether you‘re moving your site to a new domain, updating directories, or switching to HTTPS for enhanced security, adjusting your WordPress URL settings is a crucial step that requires care and attention to detail.

In this comprehensive guide, we‘ll walk you through exactly how to safely change your WordPress site URLs, step-by-step. We‘ll cover multiple methods for different scenarios, share expert tips to avoid common pitfalls, and provide troubleshooting advice to help you recover smoothly if any issues arise.

By the end of this post, you‘ll be fully equipped to handle changing your WordPress URLs like a pro. Let‘s dive in!

Understanding WordPress URL Settings

Before we jump into the steps to change your URLs, it‘s important to clarify the two key WordPress URL settings:

  1. WordPress Address (URL): This is the location where your core WordPress files reside, including your admin area, plugins, themes, and uploads.

  2. Site Address (URL): This is the public-facing URL that visitors use to access your website in their browsers. It‘s what you want search engines to index.

For most WordPress sites, the WordPress Address and Site Address are the same. However, there are scenarios where they might differ:

  • WordPress is installed in a subdirectory separate from the main site
  • A large site isolates WordPress in its own location for security or management reasons
  • WordPress is hosted on a different server from the public-facing site

Understanding the difference between these two URLs is key to changing them properly. Now, let‘s look at why you might need to make a change.

Why Change Your WordPress Site URLs?

Changing your WordPress site‘s URLs is a common task that comes up in a variety of situations:

  • Moving to a new domain name: If you rebrand or switch to a more memorable domain, you‘ll need to update your URLs. According to a GoDaddy study, 20% of small businesses change their domain name within the first 2 years.

  • Migrating from local to live: Developers often build sites locally before moving them to a live server. Updating URLs is part of that migration. A WP Engine survey found 64% of developers use local tools.

  • Updating your site‘s structure: If you reorganize your site‘s folders and directories, you may need to adjust your URLs to match.

  • Adopting HTTPS: Enabling an SSL certificate to switch from HTTP to HTTPS requires a URL update. As of 2021, over 77% of websites use HTTPS for enhanced security.

  • Troubleshooting issues: Changing URLs can sometimes help resolve technical problems like redirect loops.

No matter the reason, it‘s crucial to follow the right process to avoid downtime or losing SEO rankings. In the next sections, we‘ll cover 4 methods you can use depending on your needs and access.

Method 1: Change WordPress URLs via Admin Area

If you can log into your WordPress admin dashboard, updating your URLs there is the simplest approach:

  1. Go to Settings > General
  2. Locate the "WordPress Address (URL)" and "Site Address (URL)" fields
  3. Update both to your new URL
  4. Click "Save Changes"
  5. Refresh your site and admin area to confirm the updates took effect

WordPress general settings

One important note: If the URL fields are grayed out, your URLs are hardcoded in the wp-config.php file. You‘ll need to use one of the methods below instead.

Pros of this method:

  • Easy and fast for non-technical users
  • No need to directly edit sensitive site files
  • Immediate updates across the WordPress environment

Cons of this method:

  • Requires admin access, which you may not have if locked out due to URL issues
  • Doesn‘t work if URLs are hardcoded in wp-config.php

Method 2: Change WordPress URLs in functions.php

If you can‘t access wp-admin, you can update your URLs via the functions.php file of your active theme:

  1. Connect to your site via SFTP or your hosting file manager
  2. Navigate to /wp-content/themes/your-theme/
  3. Download a backup copy of functions.php
  4. Edit functions.php and paste this snippet at the end:
update_option(‘siteurl‘, ‘https://your-new-url.com‘);
update_option(‘home‘, ‘https://your-new-url.com‘);

Replace your-new-url.com with your actual new URL.

  1. Upload the edited file back to your server
  2. Load your site to verify the URL change worked

Editing functions.php via FTP

After confirming your site loads with the new URL, remove those lines from functions.php.

This method has some pros and cons to consider:

Pros:

  • Lets you update URLs when locked out of wp-admin
  • Enables URL changes on a per-site basis in multisite

Cons:

  • Requires FTP access and comfort with editing theme code
  • Changes are theme-specific, so switching themes will revert URLs
  • Functions could be overwritten by theme updates

Method 3: Update URLs in wp-config.php

You can also change your WordPress URLs via the wp-config.php file:

  1. Access your site files via SFTP or hosting control panel
  2. Backup your current wp-config.php file
  3. Add these lines somewhere before "That‘s all, stop editing!":
define(‘WP_HOME‘, ‘https://your-new-url.com‘);
define(‘WP_SITEURL‘, ‘https://your-new-url.com‘);  

Again, replace your-new-url.com with your new URL.

  1. Save and re-upload wp-config.php
  2. Test your site to confirm the new URL loads

Modifying wp-config.php has some notable advantages and drawbacks:

Pros:

  • Takes effect regardless of your active theme
  • Gives you an alternative to access wp-admin
  • Avoids potential plugin/theme conflicts by using a core file

Cons:

  • Requires you to edit a sensitive core WordPress file
  • Can break your site if you make a mistake in wp-config.php
  • Sometimes doesn‘t update URLs across your entire site content

Method 4: Change URLs Directly in the Database

Finally, you can update your WordPress URLs right in the MySQL database. This is powerful but should be done carefully:

  1. Backup your full WordPress database
  2. Access phpMyAdmin via your hosting control panel
  3. Select your WordPress database
  4. Open the wp_options table
  5. Find the siteurl and home fields under "option_name"
  6. Edit each field‘s "option_value" to your new URL
  7. Save your changes and test the front and back end of your site

Editing URLs in phpMyAdmin

Modifying URLs in the database comes with benefits and risks:

Pros:

  • Works in virtually any scenario, even if you can‘t access files
  • Provides a "last resort" for troubleshooting botched URL updates
  • Lets you update URLs on a network-wide basis in multisite

Cons:

  • Involves directly manipulating your database (always backup first!)
  • Doesn‘t automatically update URLs in your page/post content
  • A mistake can break your whole site or cause data loss

Updating URLs in Your Content Database-Wide

Speaking of updating page/post URLs, what about all the places your old URL might appear in your site content? If you‘ve been running your site for a while, you could have hundreds or thousands of instances. Updating them manually would be a huge headache.

That‘s where a tool like Better Search Replace comes to the rescue. This free plugin lets you search and replace text across your whole WordPress database, including serialized data like custom fields.

Here‘s how to use it after migrating to your new URL:

  1. Install and activate Better Search Replace
  2. Go to Tools > Better Search Replace
  3. Enter your old URL in the "Search for" field
  4. Enter your new URL in "Replace with"
  5. Choose the tables to search (e.g. posts, postmeta, etc.)
  6. Check "Run as dry run" and click "Run Search/Replace"
  7. Preview the results and if they look good, uncheck dry run
  8. Run the search/replace again to actually update the database

Better Search Replace dry run

We love Better Search Replace because:

  • It‘s 100% free and open source
  • It handles serialized data intelligently to avoid breaking things
  • It lets you test with a "dry run" before committing changes
  • It can update URLs across your entire database in one go
  • It provides a user-friendly interface for non-developers

Note that tools like this are best used after you‘ve already updated your core WordPress URLs using the methods above. That way you‘ve laid the foundation in WordPress itself before addressing your content.

FAQs on Changing WordPress URLs

To wrap up, let‘s quickly address some common questions we hear about changing WordPress URLs:

What if changing my URLs breaks my site?

First, don‘t panic! If you backed up your site before starting (always do this), you can revert the changes by restoring your original database and undoing any file edits.

If you can still access wp-admin, try re-saving your permalink structure under Settings > Permalinks. That often resolves issues with pages returning 404 errors after URL updates.

Will changing my URL hurt my SEO?

It can, but you can mitigate problems with proper planning. Make sure to:

  • Create 301 redirects from your old URLs to your new ones
  • Update any external links to your site with the new URL
  • Submit an updated sitemap to Google Search Console
  • Monitor your rankings and traffic closely after the change

If done carefully, your SEO should recover in a matter of weeks. Google is pretty good at handling site moves these days.

Can I change URLs without changing domains?

Yes! The process is the same even if you‘re just restructuring your permalinks or shifting WordPress to a subdirectory. The only difference is you may not need to implement 301 redirects if the rest of your URL slugs stay the same.

Conclusion

Whew, that was a lot to cover! We hope this in-depth guide has given you the knowledge and confidence to change your WordPress URLs in a variety of scenarios.

To recap, always start with a full site backup. Then choose the right method for your needs:

  1. Via wp-admin if you have dashboard access
  2. Editing functions.php or wp-config.php if you‘re locked out
  3. Directly in the database for "last resort" cases

Once you‘ve updated your core URLs, use a search/replace tool to catch stragglers in your content.

Monitor your site closely afterward and don‘t hesitate to revert if you hit snags. With careful planning and execution, your URL update should be a smooth, hassle-free process.

Still have questions? Drop us a comment below and we‘ll do our best to help. Now go forth and conquer those new URLs!

Did you like this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.