How To Change Your WordPress Website URLs

SkyStra
May 22, 2021

Knowing how to change your website URL on your WordPress website is important. You may need to change your website URL for several reasons:

  • Enabling SSL (switching from http:// to https://)
  • Moving your website to a subdomain
  • Moving your website to a different directory
  • Changing your domain name
  • Migrating from a staging environment to a live website
  • Migrating from your local computer to a live website

The WordPress address and site address define the address of your website on the internet and the location of your website files, so they’re significant fields.

Sometimes, you may even need to change the address settings because you see too many redirect errors in WordPress.

There are four different ways to adjust your website URL with WordPress:

  • From your WordPress Dashboard
  • Using the functions.php file
  • Using the wp-config.php file
  • Using the phpMyAdmin application

When changing your website URL, there are two separate settings we need to update – the WordPress Address and Site Address. If you’re a beginner, this may be a bit confusing because the settings look similar, but they serve different purposes. 

The WordPress Address URL is where your WordPress website files and folders are stored, such as plugins, themes, admin pages, media files, etc.

The Site Address URL is essentially your public domain name (https://yourdomain.com) and how visitors can reach your website. 

In most cases, these two URLs will be the same, but they could be different in some cases. Major corporations that use several different applications may choose to host their WordPress website on a different server to avoid clutter and a single point of failure.

Now that we’ve cleared a few points up, let’s get started!

Here are four different ways you can change your WordPress website URL:

Change Your Website URL From Your WordPress Dashboard

This is the easiest method, and if you can access your WordPress Dashboard – we recommend using this technique. 
Log in to your WordPress Dashboard, and head to Settings > General page:

As you can see above, all you need to do is adjust your WordPress Address (URL) and Site Address (URL) values and click Save Changes at the bottom of the page to complete the operation.

As we mentioned previously – in most cases, both WordPress and Site Address are the same URL.

Once saved, please make sure to visit your website and ensure that everything was correctly updated.

Change Your Website URL Using The functions.php File

If you’re not able to access your WordPress Dashboard – this method can help you out. Log in to your website via an FTP client, or use a File Manager application in your cPanel control panel, and access the

/wp-content/themes/your-theme-directory/ 

folder. In our case, that’s

/wp-content/themes/storefront/ 

as we use the Storefront theme for our test website.

Locate the functions.php file and if you use an FTP client, download it and edit it using the Notepad or TextEdit applications. If you use a File Manager, you can edit the file directly using the Edit button:

Scroll down to the bottom of the file, and add these two lines:

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

Make sure to replace example.com with your new domain name.

Save the file and re-upload it to the same directory you downloaded it from if you used an FTP client. If you decide to use your File Manager, click Save Changes to save the changes.

Please make sure to visit your website and ensure that everything works properly.

This method will directly update the site URLs in the database each time the theme’s functions.php file is loaded.

Once you’re able to access your WordPress Dashboard and change your WordPress and Site addresses there – make sure to remove those two lines from the functions.php file.

Change Your Website URL Using The wp-config.php File

If you cannot determine the theme you need to edit or can’t find the functions.php file – you can use this alternative method. With this method – we’ll be adding site URLs to the primary WordPress configuration file – wp-config.php, which is located in the root directory of your website.

As explained previously, download the wp-config.php file via FTP or edit it directly with File Manager, and add these lines right above the “That’s all, stop editing! Happy publishing” line:

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

Make sure to replace example.com with your new domain name.

Save changes to the file (or re-upload it to your website) and then visit your website to ensure everything is up and running.

Change Your Website URL Using phpMyAdmin

The last method changes site URLs directly in the WordPress database. Log in to your cPanel control panel and click phpMyAdmin under the Databases section:

Once in the phpMyAdmin interface, find your database in the left frame and click on it:

In the right frame, find the wp_options table, and click the Browse button:

Please note that your database tables may have a different prefix.

Next, find the siteurl and home fields under the option_value column, click the Edit button to adjust them:

Change your website URL in the option_value field, and click the Go button at the bottom to save the changes.

Perform the same operation for both the siteurl and home fields.

Once completed – check your website and ensure it’s working correctly.

Additional Information

If you have problems adjusting your website URLs using one method – we recommend trying other ones to see if they help.

For example, if you see your website URLs greyed out in your WordPress Dashboard > Settings > General, this means that your website URLs are hardcoded in the wp-config.php file. Simply change the values using the wp-config.php method we described above, and you should be good to go.

Also, changing the WordPress and Site Address isn’t enough for some users as they have hardcoded old URLs in their pages, posts, and other content. To fix that, you’ll need to use a plugin to automatically search and replace all old URLs in the database with the new domain name.

We recommend using the Better Search Replace plugin, as it’s free and very straightforward to use:

Final Words

Whether you’re a seasoned WordPress user or a beginner, you need to know how to change your website domain name when using WordPress. Any of the four methods we outlined in this article will help you achieve that goal.