A brief explanation on the difference between WP_HOME and WP_SITEURL in WordPress
If you’ve done any development work with WordPress then you’ve probably noticed two similar looking rows in the database. Specifically WP_HOME
and WP_SITEURL
.
These two have always confused me.
To set the URL of your site you need to use the WP_HOME
constant, not the WP_SITEURL
constant.
The WP_SITEURL
constant does not change your site’s URL.
Confused?
The official description of what WP_SITEURL
does is “the address where your WordPress core files reside.” This is also confusing because it’s a URL, not a directory.
Don’t blame me for this, I’m just the messenger imparting the information. I don’t make the rules!
Setting WP_HOME
and WP_SITEURL
overrides the home and siteurl entries in the wp_options
database table. So that, at least, makes sense.
// NOTE: These must not have trailing slashes
define( 'WP_HOME', 'https://website.com' );
define( 'WP_SITEURL', 'https://website.com/wordpress` );
The WP_SITEURL
setting can also be used when you have moved your core WordPress files to a different directory.
One final thing to note is that when moving sites, these aren’t the only things you have to change. A full database search-and-replace for the URL strings are recommended.
Hopefully, this explanation has helped to show the difference between WP_HOME and WP_SITEURL in WordPress.
If you want to learn more, I recommend this blog post on the entire guide to the wp-config.php file – https://deliciousbrains.com/developers-guide-to-wpconfig/
If you need any help with your own website, please get in touch.