Changing The Site URL In WordPress

WordPress: Change Site URL

During development or a migration, you may sometimes find that the initial site name you generated for the WordPress site is no longer applicable or, for some other reason, needs to be modified. In this article, we are going to discuss the various options of how to modify this value so that your URL is displaying as intended.

Before we dive in, a little explanation of how the WordPress application handles the site name value. In WordPress, there are two options in the database for the URL value: Site URL and Home. When visitors navigate to the site, the WordPress application will essentially rewrite based on these values, so that the visitor is directed to the value (URL) configured in the database.

Note: It is very important to make sure that the value configured in the database is set correctly; otherwise, you are directing your visitors to unknown or different sites.

Manually Updating The Database

The first method that we are going to explore for updating the WordPress URL is to manually update this value in the database. This is the recommended method, as it will give you the most consistent result.

Let’s begin with the instructions for sites hosted in the WCP (Windows Control Panel):

  1. Login to your WCP control Panel.

  2. Next, navigate to the “PHPMyAdmin” tool and log into the desired database.

    Application_WordPress_phpmyadmin_login

  3. Once you have accessed the correct database in “PHPMyAdmin” expand the database tree and select the “WP-Options” table.

    Application_WordPress_wp_options

  4. In this step, you will need to locate the rows labeled (“option_name”). The values for the two “Site URL” and “Home” rows (“option_value”) should display the current (old) URL.

  5. Finally, select the field that contains the old URL. Double-clicking will modify the field to allow you to edit it. Now, type the new URL value into the field and press the “Enter” key.

    Note: Double check the values to ensure that they are displaying the same content.

Once these two fields are displaying the same URL values, the site URL has been successfully changed. You should now be able to navigate to the new URL and the Wordpress application will load under that URL in the address bar.

For our clients that host their site in the * cPanel/Linux * environment, please follow the steps below:

  1. Login to your cPanel control panel.

  2. Next, navigate to the **“PHPMyAdmin” tool and log into the desired database.

    Application_WordPress_phpmyadmin_login_cPanel

  3. Once you have accessed the correct database in “PHPMyAdmin” expand the database tree and select the “WP-Options” table.

    Application_WordPress_wp_options

  4. In this step, you will need to locate the rows labeled “Site URL” and “Home.” The values for these rows should display the current (old) URL.

  5. Finally, select the field that contains the old URL, the field will modify to allow you to edit it. Now, type the new URL value into the field and press the “Enter” key.

    Note: Double check the values to ensure that they are displaying the same content.

Updating Through The WP-Admin Dashboard

The Second method is to modify the URLs through the admin area dashboard. This method has some limitations as it will not necessarily modify the URL value for Posts, Pages, and some media, which can be very bothersome to locate and modify.

  1. Login to your WordPress admin area dashboard.

  2. Next, locate your “Settings” category and select "General"

  3. Now, modify the values for the WordPress Address (URL) and Site Address (URL) options to match the new URL.

Updating Through The wp-config.php File

The Third method is to add variables to your wp-config.php file that will specify the Site URL and Home values as a WordPress variable definition. This method hard-codes your wp-config file with a variable that is not flexible between environment. This variable definition works very similar to how a “site redirect” functions. It is also very easy to forget that you have made the change here, which is why we do not necessarily recommend this option. However, it is rather quick to implement.

  1. Login to your WCP or cPanel control panel.

  2. Next, select your file manager tool and access the root directory for your WordPress Application.

  3. Now, locate your wp-config.php file and edit the file.

  4. Paste the following code snippet and replace “example.com” with your new URL.

    define('WP_HOME','http://example.com');
    define('WP_SITEURL','http://example.com');
    
  5. Save the file to implement the changes.

Recommended Plugins

The Last method involves installing a plugin to your Wordpress application that can modify these values for you. A couple of these kinds of plugins that are regularly recommended are “Velvet Blues Update URLs” and "Go Live Updates URLs."

These plugins will have necessary options for not only updating the URL values but to scan through your database looking for the old URL values and updating them to the new URL value that you desire. Once the url has been modified, it is highly recommended to de-activate and delete the plugin.