It’s easy to override your WordPress site address temporarily without having to change site URL and home URL in your WordPress database. By adding a couple of lines of code to your wp-config.php, you can manually set the wp_siteurl and wp_home URL, leaving the database values in place.
The wp-config.php Code to Override The Site Url
Note: Removing these lines from your wp-config.php will revert the values back to the database settings.
When is Modifying the WordPress Site Address Valuable?
Changing the URL values with wp-config.php will allow you to load your site in a subdomain or subdirectory while it’s in development. When you are ready to go live, you can remove the definitions from your wp-config.php and you’re site will resolve to its permanent location.
Manually defining the site URL and home URL can also be effective if you are troubleshooting a site that is not resolving properly.
The Difference Between WP_SITEURL and WP_HOME
- WP_SITURL is the site address. This is the address that people type in their browser in order to reach your WordPress.
- WP_HOME is defined as the WordPress Address. This is the address where your WordPress core files reside.
More information on changing the site URL is available here.