- 84 Views
- 23/08/2024
Changing The Site URL in the wp-config.php file
Changing the site URL directly in the wp-config.php file is a method used in WordPress to define or alter the WordPress address and site address URLs directly at the code level. This might be necessary during migrations, domain changes, or when you can't access the WordPress admin dashboard to change the settings.
It is possible to set the site URL manually in the wp-config.php file.
Add these two lines to your wp-config.php, where “example.com” is the correct location of your site.
define( 'WP_HOME', 'https://example.com' );
define( 'WP_SITEURL', 'https://example.com' );
define( 'WP_SITEURL', 'https://example.com' );
This is not necessarily the best fix, it’s just hard-coding the values into the site itself. You won’t be able to edit them on the General settings page anymore when using this method.