The website URL is an important thing to deal with. Many webmasters are still redirecting their old HTTP website URLs into HTTPS. They are a bit afraid to change the site URL on the core files. Yes, it is a little tricky scenario to change the website’s URL. It will affect your whole site sometimes.
You can remove unnecessary redirects so that the site will load faster. The speed matters always.
Website URL changing not every time for redirection. There are other reasons that are also involved in changing the URL. By reading this article without any issues you can change your website URL. There are major 4 methods that I am going to list here and any method you can opt for changing the URL.
Sometimes you may come across 2 URLs in the configurations.
One is WordPress Address and another is Site Address.
What is the difference between both URLs?
Site Address
Site Address is nothing but it is the URL user types to reach out to your blog or website. That URL is followed by the search engine to find your web server. So this part is clear.
WordPress Address
This URL is the URL used by the WordPress core files.
There may chance for your WordPress files will be stored under https://yourdomain.com/wp.
But your Site URL may be https://yourdomain.com/.
The WordPress Address will change if you change the WordPress core file folder. Let’s say if you change your core files from public_html/wp to under public_html/ then the Site Address and WordPress Address will be the same.
There is no separate folder for WordPress allocated here.
It can also check how you access your wp-admin login page
Either https://yourdomain.com/wp-admin or https://yourdomain.com/wp/wp-admin
I think you got the idea of how these 2 URLs changes accordingly.
We are going to check in detail how you change the login URL of your WordPress website in simple 4 steps.
Why the URL change is necessary today?
That’s a good question. I can tell you some of the scenarios which will force you to change both URLs.
Changing of WordPress folder
I have already told you sometimes you are likely to change your core WordPress folder then the WordPress Address to change. It is also possible to change the core files under the public_html instead of keeping inside the wp folder.
SSL installed you need to add HTTPS before the link
After the SSL installation, you people may face your website still loading with http://. This can also be done by these URL change steps.
Remove redirections.
The SSL is so important for any website. The site with SSL is the reputation among the world web. So after installation of SSL, we have to change the URLs to apply the SSL certificates.
What we will do to get the secured link for all websites,is apply force redirect to the whole website into https://.
The redirection can be removed completely if you apply any of these steps to change the URLs.
To change the entire domain name
The domain name change also possible. But it suggested that you need to purchase the domain name before the changes.
Adding WWW to your domain
Some of you noticed that the domain name will contain either www or without www. So if you like to add www before your domain name can also possible.
There are some pre-requisites before attempting any method.
- Taking full backup 2 methods ( If one restore failed then the second backup can use)
- Access to your WordPress Dashboard
- Access to your hosting control panel
- Install FTP client ( Eg – Filezilla )
- Before changing your domain name you need to purchase the domain name first.
Coming into pre-requisites you can opt Backup and restore free or with the help of any plugins like Updraft plus.
You can also download the Filezilla from here. Please note that you have to create an FTP user in your control panel before using the FileZilla.
Let’s dive into the methods
Method1:
Using the WordPress dashboard
Primarily access your WordPress dashboard and move to the Settings >> General Settings
There you will see the previously explained both URLs.
change the URLs as you prefer and press save settings.
Note: The new URL will be affected immediately. Clear your cache and login into a new wp-admin link. Also, note that you need to ensure your web address, the wrong move will throw an error while loading the new URL.
If accidentally entered the wrong URL then move to the next step that editing the wp-config.php file.
Note:- The URL section may sometimes hideout, so it is obvious that some of your other files are directly hardcoded with this file. So you need to move the next method to change the URL
Method 2:
Change the WordPress website URL with wp-config.php file
Wp-config.php file is very important to file within WordPress. So be careful to deal with it.
You need to find the Wp-config file within the WordPress folder. For this, you can access either file manager through hosting control panel or you can open FileZilla and search for this file.
Then you ave to find this section to edit.
define(‘WP_HOME’,’https://yourwebsite.com’);
define(‘WP_SITEURL’,’https://yourwebsite.com’);
Change the URL accordingly in this file.
Here I have changed as
define(‘WP_HOME’,’https://www.yourwebsite.com’);
define(‘WP_SITEURL’,’https://www.yourwebsite.com’);
And save the file and verify that site is up and running.
Method 3:
change the URL via PHP myadmin panel
Before entering into this method please take your database backup. The database can be backup by the plugin or within the control panel. So after you need to enter the PHP myadmin via a control panel.
If you are managing more than single databases, please refer to wp-config.php for your database name. After noting down the DB name you need to select the DB name left side option in PHP myadmin.
You can expand the list by clicking the + icon on the left side and find wp_options. Here wp will be your table prefix which is also mentioned on the wp-config.php file. After expanding the wp-options file there you can see the site URL and Home tables. So you have to edit these files, in order to change the URLs in a change in DB.
After the change, you have to press GO on the bottom of the page.
Again you have to check the site working by clearing your cache.
Method 4:
Change the WordPress website URL using WP CLI
This method is not common for webmasters. Because WP CLI is commonly not available some of the hosting providers like Dream Host on their WordPress managed hosting plans.
The WordPress Command Line or WP CLI is another utility for managing your WordPress site over the command line. Simple we can say all the managerial activities can be maintained with the command.
Let’s say if you want to install plugins you have to enter the
wp plugin install Plugin_Name
wp plugin activate Plugin_Name
These are the major operations can be done with the WP CLI
- List the Available WP-CLI Commands
- Update WordPress via WP-CLI
- Update WordPress Plugins using WP-CLI
- Install & activate WordPress Plugins & Themes
- Installation and usage of WP Doctor
- Installation and usage of WP Profile
Now we can see how to change the Home and Site URL with the WP CLI utility.
You have to enter this command to update the URLs.
wp option update home https://newdomain.com
wp option update siteurl https://newdomain.com
What will be next after changing your URL?
The WordPress dashboard and website URL itself we had changed above. But what about internal links that are still using the HTTP://.
Here I am giving detailed steps to clear these errors also. The above methods are only effective when you are just starting your website and the site is under construction.
The WordPress plugins are also using the old URLs and these links need to change inside the database. Here I am giving simple steps to change all the URLs into https:// if you had changed the site and home URL by using the above methods.
If the site is completely down then definitely you need to change the DB URLs for better workings.
There are 2 conditions to change web addresses.
Condition 1:
First condition your website is completely down after the change of your URL. I have also faced this issue.
Follow the below steps to complete the URL change.
Enter into the PHP myadmin and check the wp-options ( check Method 3).
Then Select your Database left side
Go to SQL tab
Enter this query
UPDATE wp_options SET option_value = replace(option_value, 'currenturl.com', 'newurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';UPDATE wp_posts SET guid = replace(guid, 'currenturl.com', 'newurl.com');UPDATE wp_posts SET post_content = replace(post_content, 'currenturl.com', 'newurl.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'currenturl.com', 'newurl.com');
Note: Currenturl is http://domainame.com and newurl https://domainname.com. WP_ is database table prefix.
Press the Go button for saving the settings.
Condition 2:
Your website is working and can access the wp-admin dashboard
Here I will introduce a lightweight plugin called Search and replace, which will help you find all the links with the http:// and can be replaced with https://. This plugin mainly used for fixing the mixed contents, which mainly faced after enabling the SSL for your site. Even though your website is loading with https:// but some of the contents like images always loads with https://. So we have to replace all the internal links with https://
Please download your database before doing anything. You can take backup with this plugin itself.
Install this plugin and activate it.
Move to the Tools >> Search and Replace from the WordPress dash board.
There you will see 5 tabs after opening the Search and Replace.
The Backup database can be used for downloading your existing databases ( file name will be like this DBname.sql )
The Search & Replace is we are using now.
Search for: http://
Replace with: https://
CSV Format Search/Replace: no need to fill
Select tables: Here you can select All tables, you really don’t know where the files are.
Dry Run: This is the method of showing only results and suggestions for altering the strings inside tables. So primarily you have to select the Dry Run. Check each suggestion to replace and move forward.
Save changes to Database: saving the changes to DB after removing the Dry Run tick mark.
Important:- Primarily you have to search the entries by applying DRY RUN.
After that change the Dry Run and select the Save changes to Database. It will completely replace your http:// URL into a new one.
Note: you have to clear your cache using the WordPress cache plugin setup.
Check the website for all the functions working or not.
Note: If any unexpected error found then restore your database or restore with the whole backup you had taken.
Important note:
The URL change is to inform google by changing the web address on the SEarch console. SO that you don’t lose your SEO rankings.
Final thoughts
These are the simple method to change the URL for your WordPress website. Before changing, I must say you have to take backup and after changing the URL you need to check the SEO rankings.
I think this article helps to change the WordPress website URL. Also, I want to know your thought regarding these methods.
Share this article, so that your friends can make use of this method.
2 comments
Hello Sir,
Thanks for sharing this very informative and well illustrated post for changing url of website.
Usually it seems tricky nd tough to do it by self. But definitely after going through this article, one can easily do so.
Regards,
Raksha Kumawat
Hello Shiju,
A very informative and comprehensive post.
Thanks for sharing this complete step by step guide to change site URL and home URL in WordPress. I really appreciate the way you explained making the concept very clear as it is very tough to change this by self. I am quite sure this post will definitely going to help many of us.
Thanks and Keep sharing more similar and informative posts.
Regards,
-Rijhu