← ServerPilot Docs

How to Change the WordPress URL

The WordPress settings named "Site Address (URL)" and "WordPress Address (URL)" (available in your WordPress Dashboard under Settings → General) are used to set the public URL of your site. When WordPress receives a request to your site and the requested URL does not match the "Site Address (URL)" setting, WordPress will redirect the browser to a URL using the protocol and domain name you have set as the "Site Address (URL)".

Unless you're a WordPress expert with the need for a non-standard and complicated WordPress installation, you should keep "WordPress Address (URL)" set to the same value as "Site Address (URL)".

Changing the WordPress URL when you can't access your site

If you can't access your site because WordPress keeps redirecting your browser to the wrong URL, it's likely that you need to update these two WordPress URL settings. Of course, if you can't access your site because these settings are wrong, you can't update these values through the WordPress dashboard.

To change the WordPress URL when you can't access the WordPress Dashboard, you can either use the wp command (also known as the WP-CLI) or edit the file wp-config.php.

Changing the WordPress URL using the WP-CLI

To update the WordPress URL using the WP-CLI, first SSH into your server as your app's system user.

Next, use the following command to change directory to your app's public directory (replace APPNAME below to the name of your app):

cd apps/APPNAME/public

Finally, run the following two commands to update the WordPress URL settings. Replace example.com with your app's domain name.

wp option update home 'http://example.com'
wp option update siteurl 'http://example.com'

Once you've run these two commands, you should be able to access your WordPress site again.

Changing the WordPress URL through wp-config.php

To change the WordPress URL through your app's wp-config.php, SSH or SFTP into your app's public directory and edit the wp-config.php file in that directory. Add the following two lines immediately after the first line of the file (that is, add these after the line that says <?php). Replace example.com with your app's domain name.

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

Once you've added these two lines, you should be able to access your WordPress site again. Note that WordPress won't let you edit these settings through the WordPress Dashboard when you have set them in your wp-config.php file. That's ok. If you need to edit these values again in the future, you can edit them in the wp-config.php file.

Last updated: May 20, 2023

Launch your first site in 5 minutes