Do you wish to change your WordPress URL? Are you confused regarding how exactly you are going to do so? Well, there might be several reasons for which you have to change your WordPress URL, a few of them being migrating your website, changing the domain name of your website. The WordPress address, as well as your site address, are extremely important. The WordPress address is used to locate your WordPress on the internet and the site address gives the location of the files on your website.
Here, in our article, we have mentioned the different ways by which you will be able to change the URL of your WordPress website:
Why do you need to change your URL?
- You are required to change your site URL while you are moving from a local server to a live site.
- The site’s URL will have to be changed while moving the website to a new domain name.
- Sometimes, moving WordPress to another directory may require you to change the domain name.
- You will also have to change your domain name while you are shifting WordPress from HTTP to HTTPs.
Read More: WordPress Sms Plugin
What are the different ways to change the WordPress site URL?
Given below are four different ways by means of which you will be able to change the WordPress site URL:
Changing the URL from the admin area:
The easiest way to change the site URL is to change it directly from the admin area. This method is suitable for you if you have access to the WordPress admin area. All you need to do is log in to your WordPress website and go to the Settings option. From there, click on General and from the WordPress Address and the Site Address options, you will easily be able to change the URL.
You must save the changes before you leave the page. Otherwise, the changes will not be stored in the Settings. You can open your website once to check whether everything is working fine or not.
Changing the URL by using the functions.php file:
This method is useful for those WordPress users who do not have access to the admin area. The main advantage of this method is that the site URL will automatically be updated in the database of your website. Every time the functions file is loaded, the database of your website will be updated.
You will have to connect your WordPress website by using an FTP client. Now go to the /wp-content/themes/your-theme-folder/. From there, you will have to find out the functions.php file. You can easily edit the file using text editors like Notepad. Now, you will have to add the following lines of code at the bottom of the functions.php file:
- update_option( ‘siteurl’, ‘https://example.com’ );
2. update_option( ‘home’, ‘https://example.com’ );
You will now be able to save your changes and upload your file back to your website hosting by using FTP. You must not forget to remove these two lines of code once things get normal.
Changing the URL by using the wp-config.php file:
This method is especially recommended for WordPress users who are not being able to locate this functions.php file or who do not know which theme they exactly wish to edit. Here, you will have to add your website URL to the wp-config.php file. You will find this file in the root directory of your website. This file contains various important settings of WordPress.
You need to connect your WordPress website by using an FTP client. Now you will be able to edit the wp-config.php file. You will just have to add the following lines at the end:
- define( ‘WP_HOME’, ‘https://example.com’ );
2. define( ‘WP_SITEURL’, ‘https://example.com’ );
Save the changes and upload the file to your server. Check whether your website is working fine or not.
Changing the URL directly in the database:
The last recommended method for changing the URL is by changing the URL directly in the database. This can be done with the help of phpMyAdmin. In phpMyAdmin, you will have to click on your database which is present on the left-hand side of your screen. Now, you need to scroll down and select the wp_options table. The name may differ depending on the prefix of your database. You will now be able to edit the home rows and the site URL. Enter your URL and click on Go. Once this has been done, you will be able to access your WordPress only by using the new URL.
So, these are some of the most basic ways which will help you to change your WordPress URL. Apart from these methods, few plugins are also available using which you can change your URL. Do let us know which method you are going to use in order to change the URL of your WordPress site.