There are several reasons why you may need changing your WordPress URL. For example, You may need to update site URLs when you move WordPress from a local server to an active site. If you moved your WordPress site to a new domain name, you will need to modify the site URLs to reflect the change. If you move WordPress to a different directory, for example removing /WordPress/ from the WordPress URL.
You will also need to change it when you move WordPress from HTTP to HTTPS. Other than that, you may need to change your WordPress address settings if you see too many error redirects in WordPress or when troubleshooting other WordPress errors. In this post, we will share different ways to easily change the URLs of the WordPress site. This guide will be especially useful when you fix common WordPress errors or move a WordPress site.
what do you need for changing WordPress URL?
When you change the URL of the WordPress site, you will need to update two separate settings:
- WordPress Address
- Site Address
What is the difference between the WordPress address (URL) and the site address?
WordPress address (URL) is the address where WordPress files and folders are stored, including the admin pages, media files, plugins, themes, etc. But the site address (URL) on WordPress is the public part of the website. This is what your visitors will write to access your website. This is also the link you put on your business cards.
For most users, the WordPress address and site URL will be exactly the same link. However, in some cases, large companies may host their WordPress site on a different server because their corporate website has many other applications, and they want to isolate where each application is hosted. But for most users, these two WordPress URLs must remain the same.
Also, we can say that the “Site Address (URL)” option is the address you want users to enter in your browser to access your WordPress blog. The “WordPress Address (URL)” setting is the address where the main WordPress files reside.
Changing WordPress URL from Admin Area
Just log into your WordPress site and go to Settings” General Page. From here you can change the URLs of the WordPress site under the options ‘WordPress Addresss’ and ‘Site Address’. The WordPress address and site address are usually the same address.
This method is the easiest. If you can already access the WordPress admin area ” dashboard “, we recommend using this method.
Changing WordPress URL by Using functions.php File
The advantage of this method is that it updates the site URLs in the database. WordPress updates the database option for site URLs whenever the features file is loaded.
- Simply log in to your WordPress site using an FTP client and go to /wp-content/themes/your-theme-folder/. From there, you need to locate the functions.php file and edit it using a plain text editor such as Notepad or TextEdit.
- Then you need to add the following code at the bottom:
update_option( 'siteurl', 'https://example.com' ); update_option( 'home', 'https://example.com' );
- Now you can save the changes and upload the file to your website hosting using FTP.
Changing WordPress URL Using wp-config.php File
For this method, you will add the site URLs to your WordPress configuration file called wp-config.php. This file is located in the root folder of your website and contains important WordPress settings.
here are the steps (step by step ) :
- Edit the wp-config.php file.
- After the “define” statements (just before the comment line that says “That’s all, stop editing! ), insert a new line and type: define (‘RELOCATE’, true);
- Save the wp-config.php file.
- Open a web browser and manually point to wp-login.php on the new server. For example, if the new site is located at http://www.yourdomainname.com,
- type http://www.yourdomainname.com/wp-login.php in the browser address bar.
- Log in as usual.
- Search the address bar of your web browser to verify that, in fact, you are connected to the right server. If so, in the management backend, go to Settings > General and verify that both address settings are correct.
- Don’t forget to save your changes.
- Once this is fixed, edit wp-config.php and completely delete the line you added (delete the entire row), comment it (with//) or change the true value to false if you think it is likely to be relocated.
- When the RELOCATE flag is set to true, the site URL is automatically updated to any path you use to access the login screen. This will launch the administration section in the new URL, but will not fix any other part of the configuration.
- You will always have to replace them manually.
- Leaving the RELOCATE constant in the wp-config.php file is not safe, as it allows an attacker to change the URL of the site in whatever he wants in certain settings.
- Always remove the RELOCATE line from wp-config.php once you are done.
Change WordPress URL in the Database Using phpMyAdmin
If you know how to access phpMyAdmin on your host, you can change these values directly to restart your site.
- Back up your database and save the copy offsite Log in to phpMyAdmin.
- Click the link to your databases. A list of your databases appears. then, Choose what is your WordPress database. All tables in your database will appear on the screen. In the list, search for wp_options.
- Note: The wp_ table prefix may be different if you change it during installation.
- then, click the small icon indicated as Browse. A screen opens with a list of the fields in the wp_options table. Under the option_name field, scroll down and search for siteurl.
- Click the Edit Field icon, which is usually on the far left at the beginning of the line.
- The Edit Field window appears. In the option_value input box, carefully modify the URL information by the new address.
- Verify that it is correct and click Go to save the information.
- You must return to your wp_options table.
- Locate the main field for the table and click Edit Field.
- Note There are several table pages in wp_options. Search for the symbol > to traverse them. In the option_value input box, carefully modify the URL information by the new address. Verify that it is correct and click Go to save the information.
What to do next?
The Aftermath Once you’ve successfully changed your WordPress site URL, there are 2 crucial steps you need to take as the finishing touch:
1. Redirect URL: Despite the change, you’ll notice that most URLs of your other posts and pages still appear as an old URLs. You will need to redirect these URLs to your current address in order to avoid losing traffic.
2. Please inform Google: It is important to keep Google up to date on your website at all times so that you do not lose your current SEO. You can find the process to notify Google of the updated URL from the Google Search Console.
We hope you found this article useful and we’d love to know you if you have any suggestions or questions. Before leaving, we would like to remind you that although modifying the URL of the WordPress site is simple, it is necessary to be careful. Since some methods involve editing important files, there is a high probability that the site will break or fail.