Accidentally changing the “WordPress Address (URL)” or “Site Address (URL)” fields can make your website inaccessible and prevent you from accessing the admin dashboard.
If this has happened to you, you can correct the addresses in the database or through the “wp-config.php” file. Below, we explain both options to help you regain access.
If you want to change your domain, keep in mind that updating these addresses is only part of the process. You will also need to configure the new domain and review the SSL certificate, the URLs stored in the database, and the redirects from the previous domain.
Before you start, back up your database and “wp-config.php” file.
Restore the WordPress URL from the database
There are two options in the WordPress database that you need to check:
- “siteurl”: the address where your WordPress files are located.
- “home”: the address visitors use to access your website.
These addresses are usually the same. However, they may differ if WordPress is installed in a subfolder. For example, “siteurl” could be “https://yourdomain.com/wordpress” and “home”, “https://yourdomain.com”.
In this case, follow these steps:
- Access the database for your WordPress installation through phpMyAdmin.
- Select the “wp_options” table, or “yourprefix_options” if your installation uses a prefix other than the default WordPress prefix.
- Open the “Browse” tab.
- Find the rows where the “option_name” field is “siteurl” or “home”. You can use the “Search” tab if they do not appear on the first page.
- Click the “Edit” button for the row you need to correct and update the “option_value” field with the correct address. Include “https://” if your website has HTTPS configured, or “http://” if it does not, and do not add a trailing slash “/”.
- Click “Go” to save your changes and repeat the process for the other option if it also needs correcting. Button names may vary depending on the language of phpMyAdmin.
- Check that you can access your website and the admin dashboard.
Important: if your “wp-config.php” file contains the “WP_HOME” or “WP_SITEURL” constants, their values will override those in the database. In this case, also review the following section.
Restore the WordPress URL with the wp-config.php file
In this case, follow these steps:
- Connect to your Cloud VPS using your file transfer client. Whenever available, use SFTP or FTPS to ensure the connection is encrypted.
- Locate the “wp-config.php” file for your WordPress installation and open it with a text editor.
- Check whether the “WP_HOME” and “WP_SITEURL” constants already exist. If you find them, update their values instead of adding them again.
-
If they do not exist, add the following lines just before the comment telling you to stop editing, near the end of the file. Depending on the language, it may appear as “/* That's all, stop editing! Happy publishing. */” or similar wording in another language:
File
File: wp-config.php
define( 'WP_HOME', 'https://yourdomain.com' ); define( 'WP_SITEURL', 'https://yourdomain.com' );Replace the example addresses with those of your website, without a trailing slash and using the protocol you have configured. If your WordPress files are in a subfolder, include that subfolder in “WP_SITEURL”.
- Save your changes and, if you edited a local copy, upload the updated file to the server.
- Check that you can access your website and the admin dashboard.
Important: these constants override the addresses stored in the database, but do not change them. While the constants are defined, you will not be able to change these addresses in the WordPress settings. If you remove the constants later, WordPress will use the database values again, so make sure you correct them before removing the constants.
And that’s it! If everything is working correctly, your readers or customers can enjoy your WordPress website again as usual 😉
Remember, if you have any questions about this or any other matter related to your servers at Clouding, feel free to email soporte@clouding.io We’re here for whatever you need. Just ask us!