If you need to migrate your WordPress site 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. Click here to learn more about WordPress Hosting.
These settings can be adjusted directly in the WordPress admin dashboard from Settings >> General or you can make these modifications to wp_options table in the database.
In this article we will touch on the following:
- WordPress WP_HOME and WP_SITEURL settings
- Changing WordPress URLs from admin dashboard
- Changing WordPress URLs directly from database
- Detect and change WordPress URL with RELOCATE
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 (URL) / WP_SITEURL: The address where your WordPress core files reside.
- Site Address (URL) / WP_HOME: The address typed in a browser to reach your WordPress blog.
|WordPress Address (URL) / WP_SITEURL||Site Address (URL) / WP_HOME|
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 https://www.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 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.
- Edit your wp-config.php file.
- Define your WP_HOME and WP_SITEURL settings by inserting these lines towars the top:
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.
You may need to search for them with the Filter rows function at the top.
Enter in your new value in the option_value 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:
- Now visit your https://www.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.
Looking for more guides? Check out our WordPress How To Articles!