Select Page

How to change WordPress URL from wp-config (wp-config.php) file

How to change the WordPress URL using the wp-config.php file

To change WordPress URL you need to put this code into the wp-config.php file:

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

Change the “https://example.com” to your domain name.
Be mindful of some gotchas:

  • The protocol (http vs. https) matter a great deal. Most sites run with https
  • The domain name should not have a / at the end of it
  • Hackers love the wp-config.php file. After you edit it, change its files permissions to 444 to make it hard to tinker with.
  • While you have the wp-config.php file open, make sure the SALTS are good. More on that