Thursday, 12 December 2019 10:38

How To Change Your WordPress URL (2 Options)

Follow the different methods below to change your WordPress URL, also known as the WordPress Address (URL) and or Site Address (URL). Be careful when editing these values, as you could bring your entire site down if they are entered incorrectly.

You can change the domain name for your WordPress site any time you like, but there are a few important settings that must me made in order to make the switch.

Make sure to carefully follow the steps below to ensure it's done properly.

Several reasons to change the URL

The following are instructions for moving a WordPress installation from one URL to a different one. There are different cases for moving a WordPress install, as shown below.

Case #1 — Moving from a subdirectory

The first case is when a WordPress site moves from a sub-directory to its parent domain. For example:

  • Move from http://example.com/blog
    to
  • http://example.com

If you've already moved your domain to a new URL, you are not able to log in since WordPress is configured to use the old URL.

Case #2 — Adding or removing www

Another reason to update your URLs is if you need to add or remove www from your domain. For example, if you're using Cloudflare with DreamHost, you need to add www to your domain. So if it was previously example.com, you would change it to www.example.com.

After adjusting the URL, you may also see a browser redirect error when viewing your site. It may say "Too many redirects" or "The page isn't redirecting properly".

Case #3 — Adding 'https' to the URL

If you're using an SSL certificate, the first part of the URL changes from 'http' to 'https'. If you've already made this change, you are not able to log in since WordPress is configured to use the old URL.

Case #4 — Moving to a new domain

The last case is when a WordPress site moves from one fully hosted domain to a different one. For example:

  • Move from http://example.com
    to
  • http://example.com

If this option applies to your site, view the following article for full instructions on moving a WordPress install to a different domain.

Different ways to change the WordPress URL

The following two options explain how to change your HOME and SITE URL so you gain immediate access to your WordPress site and dashboard.

Option 1 – Changing the HOME and SITE URL using phpMyAdmin

If you've already made any of the changes above, you're not able to log into your dashboard. You can instead use phpMyAdmin to update the HOME and SITE URLs.

Visit the following article for more information on how to log into phpMyAdmin:

  1. Open phpMyAdmin.
  2. Click your database in the left pane. Several tables appear below it. Click on your wp_options table.
    How To Change Your WordPress URL (2 Options)
  3. Locate the 'siteurl' and 'home' rows. Click the pencil icon next to each to edit.
    When you scroll over these options, "browse" will appear.
    How To Change Your WordPress URL (2 Options)
  4. Click the pencil icon next to each to edit.
    How To Change Your WordPress URL (2 Options)
  5. Alter the URL by typing in a new one.
  6. Click the Go button to save the settings. Do this for both the 'siteurl' and 'home' options.

You should now be able to log into your site at example.com/wp-login.php.

Option 2 – Changing the URLs in your wp-config.php file

You can also change the URLs in your wp-config.php file. This is a little easier than editing your database and will give you immediate access to your site.

  1. Log into your site using FTP or SSH.
  2. In your WordPress directory, edit the file titled 'wp-config.php'.
  3. In that file, add the following lines just above /* That's all, stop editing! Happy blogging. */.
    define('WP_HOME','http://example.com');
    define('WP_SITEURL','http://example.com');
  4. If you visit your site now, you'll see you can log in.

Although this gives you immediate access to your site, the database is still not configured to use the correct HOME and SITE URL.

Verifying the new HOME and SITE URL

If you used options #1 above, the HOME and SITE URLs were updated in the database. You can confirm your site is now using the correct URLs in your dashboard.

    1. Log into your WordPress Dashboard.
      How To Change Your WordPress URL (2 Options)
    2. Navigate over to Settings > General.
      How To Change Your WordPress URL (2 Options)
    3. Here you'll see the HOME and SITE URL your WordPress site is configured to use.

If you used Option #2, the database did not update your HOME and SITE URL. On the 'Settings > General' page you'll see the entries are grayed out with the values you entered in your wp-config.php file:

How To Change Your WordPress URL (2 Options)

You should now use plugin Better Search Replace to update all URLs in your database to the new URL.

Once updated, remove the lines from your wp-config.php file. Check the 'Settings > General' page again and you'll see those fields are no longer grayed out.

Read 3453 times Last modified on Thursday, 12 December 2019 11:42

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.

x

Looking for a FREE WooCommerce Theme?

WooVina is an intuitive & flexible, free WordPress theme offering deep integration with WooCommerce. 100% Love It Guarantee!