WordPress - Changing the Site URL and Home Settings
If you need to migrate your WordPress website, or change the location of your WordPress installation it's good to keep in mind how WordPress keeps track of itself via the WordPress Address and Site Address settings.
WordPress WP_HOME and WP_SITEURL settings
There are 2 WordPress options that you can adjust to change the behavior of how WordPress works.
- WordPress Address / WP_HOME The address where your WordPress core files reside.
- Site Address / WP_SITEURL The address typed in a browser to reach your WordPress blog.
|WordPress Address / WP_HOME||Site Address / WP_SITEURL|
As you can see from the example above, I have my WordPress core files stored inside my /public_html/wp directory so that they aren't clogging up my root directory.
However I still want people just to type in http://example.com to get to my WordPress site, so I've left that set as my Site Address so WordPress knows this is what I want displayed instead of the core files location.
This is just one example of what can be done with WordPress URL settings. You might also need to modify these settings after moving your WordPress website to a new server, or testing a new structure for your website.
Change WordPress address with wp-config.php file
The easiest way to modify your WordPress URLs is via the wp-config.php file. If you've moved your WordPress site or are trying to test it from a temporary URL, this also might be the only method that works for you.
- Edit your wp-config.php file.
- Define your WP_HOME and WP_SITEURL settings by inserting these lines towars the top:
define('WP_HOME','http://yourdomain.com'); define('WP_SITEURL','http://yourdomain.com'); // ** MySQL settings - You can get this info from your web host ** //
Change WordPress address in admin dashboard
You can also adjust your WordPress URL settings directly from the admin dashboard. This method will typically work if you haven't moved your WordPress installation and aren't having any issues access it.
- Login to WordPress admin dashboard
- Click on Settings >> General
- Fill in your WordPress Address and Site Address and click Save.
Change WordPress address directly in the Database
You can also diretly modify your WordPress URL settings in the WordPress database using the phpMyAdmin tool.
- Backup your database in cPanel prior to making changes.
- Use phpMyAdmin to manage your WordPress database.
- Select your WordPress database from the left.
- Then select your wp_options table.
Your wp_ prefix may differ depending on your install settings.
- Click Edit beside either the siteurl or home entries.
- Enter in your new value in the option_valuie field, then click Go
Detect and change WordPress address with RELOCATE
If you're having issues accessing your WordPress dashboard, you can have WordPress automatically try to figure out what the correct WordPress Address should be using the RELOCATE flag in your wp-config.php file.
- Edit your wp-config.php file.
- At the top of the file add a define('RELOCATE',true); line:
define('RELOCATE',true); // ** MySQL settings - You can get this info from your web host ** //
- Now visit your http://example.com/wp/wp-login.php page in your web browser.
Be sure to type in the path of your WordPress core files before wp-login.php
- Log into your WordPress dashboard as you would normally.
- If you navigate to Settings >> General, you should now see that WordPress has automatically populated the WordPress Address (URL) field for you, with the path to your WordPress files.
Thank you for your feedback!