Update the WordPress Site URL and Home URL

 on

The WordPress Site URL and Home URL settings need to be checked when migrating websites to another server or subdirectory. In some cases, the actual WordPress file path shouldn’t be the same as the website address typed in web browsers.

WordPress Address (URL) (Site URL): absolute file path to your WordPress core files. For example, domain.com/wordpress could be ~/public_html/wordpress or /var/www/html/wordpress.

Site Address (URL) (Home): web address to reach your WordPress site.

Below we’ll cover multiple ways to update this information.

Update the WordPress Site URL and Home URL in WordPress 

Using the WordPress Dashboard

This is the easiest method.

  1. Log into WordPress.
  2. On the left, select “Settings” and “General.”
  3. Edit the WordPress Address (URL) / Site URL and Site Address (URL) / Home as necessary.
    wordpress-wordpress-url-site-url.png
  4. At the bottom select “Save Changes.”

Editing wp-config.php

This method is helpful when current settings prevent you from accessing the dashboard. Note that it prevents you from making changes to the URLs in the WordPress dashboard.

  1. Log into your server via SSH, FTP, or other server management software.
  2. Navigate to your WordPress root directory.
  3. Edit the wp-config.php file.
  4. Add the following above the MySQL settings, replacing the URLs as necessary:
    define(‘WP_SITEURL’,’https://example.com’);
    define(‘WP_HOME’,’https://example.com’);
  5. Save changes.

If you’re unable to access your WordPress dashboard, you can add the following line near the top of your wp-config.php file to auto-configure the site URL and regain access:

define(‘RELOCATE’,true);

 

Third Party Software

MySQL Database Updates with phpMyAdmin

cPanel servers include phpMyAdmin which can be used to edit MySQL databases. We recommend backing up your database beforehand.

  1. Log into phpMyAdmin.
  2. Select your WordPress database on the left. The format will usually be “serveruser-wpXXX.”
  3. The selection will expand to list database tables. Select the table with the suffix “_options.”
  4. Double-click on the URL in the “siteurl” and “home” rows to make changes. Changes are saved automatically.
    phpmyadmin-wordpress-siteurl-home.png

WP-CLI Terminal Application

Advanced users with Secure Shell (SSH) access can use WP-CLI to make updates. Some hosting providers include WP-CLI by default.

  1. Log into SSH.
  2. Navigate (cd) to your WordPress root directory.
  3. Ensure you’re in the correct WordPress directory:
    wp option get siteurl && wp option get home
  4. Update the site URL:
    wp option update siteurl https://newsite.com
  5. Update the home URL:
    wp option update home https://newsite.com