
Suppose you want to change the URL of your website. And you are looking for ways and different methods to change the URL in WordPress. This article will be helpful for you as you will find different methods for doing so.
Changing the URL in WordPress is not a difficult task. There are several ways to do it. You can choose anyone that you think is easier for you. Before discussing the methods let us have a little knowledge about URLs, Why to change and what kind of URL is the perfect choice.
URL is the short form of Uniform Resource Locator. It is a unique web address for your site that is used to locate and identify the posts, pages, and all the resources used to make a website in WordPress.
Uses Of URL In WordPress
URLs are of great importance in the world of the internet. These are the paths through which we can reach our desired destination. Here are some main uses of URLs in WordPress.
Identification Of Posts And Pages
URLs are used for the identification of posts and pages on a website. They are also used to locate pages and posts. Different images, videos, and files are tracked with the help of URLs. Every page, post, video, image, etc. has a unique URL that allows users to navigate to and access them.
Used In SEO
URLs play an important role in SEO (search engine optimization). They affect the ranking and visibility of websites on SERPS (search engine research pages). WordPress allows you to customize the permalinks and URL settings to make the website SEO-friendly.
For Linking
URLs are most often used to link different pages and posts on a website. They are used to access the interesting contents of the website as they are a source of navigation between different resources of the website.
For Redirections
If a user wants to change the URL of a page or post a new URL can be created to redirect it. This will allow the users and search engines to locate the content even if the URL has changed.
Permalinks
Permalinks are the permanent URLs for the pages and posts that can be customized to add post ID, name, date, category, etc. These Permalinks are used to customize the URL in WordPress.
How To Change The URL In WordPress (6 Easy Methods)
Here are a few methods through which you can change the URL. Choosing the appropriate method depends on desired results and certain circumstances.
1. Change The URL In WordPress Through The Admin Panel
This is the easiest method and a perfect choice for beginners to change the URL of any site. You need to follow these simple steps to change the URL.
- First login to your admin panel in Wordpress.
- Click on settings, in the left-hand sidebar.
- Then select General.
- Here you will find two fields, “WordPress Address (URL)” and “Site Address(URL)”. Here you can update the URL to a new domain or subdomain.
- Also include http:// or https:// as applicable.
- Now click on save changes given below.
- On saving the changes you might log out of the website automatically. Again log in and check that the website is working and loading properly after changing the URL.
2. By Editing The .htaccess File Manually
The URL of the website can also be changed by editing the .htaccess file. Follow these steps.
- Access the website’s root directory by logging in to the website’s hosting account or using an FTP client.
- Search a file .htaccess in the root directory. If you don’t find it then enable it to show the hidden file.
- Now you can open the file in a text editor like Notepad or WordPad.
- Search for the line starting with “RewriteEngine on” and add the following code below it, in the new line.
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule (.*)$ https://www.newdomain.com/$1 [R=301,L]
- Must replace the “olddomain.com” with the older name and “newdomain.com” with the new domain name.
- Save the changes in the file and upload it back to the root directory of your website.
- Now test if the new domain name is working properly by opening the website in your browser.
3. Changing URL In wp-config.php File
It is also the most common way to change the URL of WordPress in the wp-config.php file. The values in this file will override the settings of your admin panel.
- The wp-config.php is located in the root directory of the WordPress site. You can access this file through SSH, FTP, or WP-CLI.
- The fields of the URL are often not editable because they are hard-coded in the file.
- Add the following code of two lines in the file, just above the line that tells about stopping editing.
define( ‘WP_HOME’, ‘http://yoursiteurl.com’ );
define( ‘WP_SITEURL’, ‘http://yoursiteurl.com’ );
- Now save the changes in the file and close it.
- Now in your WordPress admin, go to general settings.
- You will see these two lines are grayed out.
- You can not edit these fields until you remove those two lines of code in the file.
- Now if you want to access the settings again in your dashboard, you need to remove these two lines of code from the wp-config.php file.
4. Change The URL Directly Through The Database
It is also a known method of changing URLs and is often used as the last option. Making changes in the database is a risky method. So good practice is to make a backup of the database before making changes to it.
You can use a plugin for data backup like WP-DB-Backup is a plugin used for database backup.
- Access the database using the phpMyAdmin tool in your web hosting control panel.
- Now search for a table wp_options. In this table, you will have the site settings including the Site URL.
- In the field find the site URL and home options. Edit the option_value field to add the new URL of your desire.
- Now save the changes by clicking the “Apply” or “Save” option.
- Now login to your WordPress site and update the permalinks.
- Go to settings >permalinks.
- Now save changes to update the new URL.
5. Change The URL Through A Custom Function
Another method of changing the URL is through the custom Function. Back up your site before making changes.
It may have consequences like breaking links and may cause different issues with themes and plugins. Follow these simple steps to change the URL by this method:
- You can update the site URL option and home URL option in the database by using the update_option() function.
- Add the following function to the function.php file to your WordPress site.
function change_wp_url() {
update_option(‘siteurl’,’https://www.newurl.com’);
update_option(‘home’,’https://www.newurl.com’);
}
- You can also create a new plugin file and add the function there.
- As the function is added. Now call this function through the WordPress dashboard by navigating to the plugins menu.
- Now find the created plugin and click on the ‘Activate’ button.
6. Change The URL In WordPress Through Plugins
There are different plugins available that can be used to change the URL in WordPress.
AIO SEO Plugin
This is an all-in-one SEO pack popular for Search Engine Optimization. As specifically this is not designed for changing the URL in sites, but it has a feature of changing the URL as well. Follow the steps to change the URL by AIOSEO:
- Install and activate the plugin in the Plugins section of the WordPress dashboard.
- In your WordPress go to the ALL in One SEO section and select “General Settings”.
- Now click on the Performance tab and select the URL settings.
- Here you will enable the “Canonical URLs” option. This is to make sure that the search engine will recognize your new URL as the primary URL of your website.
- In the HomePage URL field add the new URL of your choice.
- Now click on the Update button to save the changes.
- Now check for the broken links on your website. If you find any, replace them with new URLs.
- Now you need to test your website to make sure everything is working normally.
- Now finally submit your sitemap to the Search engine to make sure they are aware of the changes you made in your URL.
Better Search Replace
- Install and activate the plugin in the Plugins section of the WordPress dashboard.
- Go to the Tools section in your dashboard and select “Better Search Replace”.
- Replace the old URL with the new one in the “Replace With” field.
- Now click on the “Run Search / Replace” button to start searching the URL and replace it with new.
- Now check for the broken links on your website. If you find any, replace them with new URLs.
- Now you need to test your website to make sure everything is working normally.
- Now finally submit your sitemap to the Search engine to make sure they are aware of the changes you made in your URL.
WP Migrate DB
- Install and activate the plugin in the Plugins section of the WordPress dashboard.
- Now go to the “Export” Tab in the WP Migrate DB settings to export the database.
- Open the database export file in any text editor like Wordpad etc.
- Find the old URL by the Find feature or by pressing CTRL+F from your keyboard.
- Replace the URL with the new URL.
- Save changes to the file.
- Now go to the “Import” option in the settings panel of WP Migrate DB and import the modified file.
- Now check for the broken links on your website. If you find any, replace them with new URLs.
- Now you need to test your website to make sure everything is working normally.
- Now finally submit your sitemap to the Search engine to make sure they are aware of the changes you made in your URL.
All-In-One WP Migration
- Install and activate the plugin in the Plugins section of the WordPress dashboard.
- Go to the “Export” option in the settings panel of the All in One Migration plugin.
- Open the file in your text editor.
- Find and replace the old URL with a new one with the “Find and Replace” feature of the text editor.
- Make sure to replace all the instances of the old URL present in the file.
- Now save changes to the file.
- Now again go to the All in One Migration setting panel and click “Import”. Import the modified file here.
- Now check for the broken links on your website. If you find any, replace them with new URLs.
- Now you need to test your website to make sure everything is working normally.
- Now finally submit your sitemap to the Search engine to make sure they are aware of the changes you made in your URL.
Update URLs In WordPress
- Install and activate the plugin in the Plugins section of the WordPress dashboard.
- Go to the settings panel of WordPress and go to Tools.
- Select Update URLs.
- In the “Old URL” field type the older URL and in the “New URL” field enter your new desired URL.
- Select the tables you want to update by your new URL. Also, select the fields you want to update with the new URL as well. You can also update the media and attachments’ URLs here.
- Now click on the “Update URL Now” button to start updating.
- Now check for the broken links on your website. If you find any, replace them with new URLs.
- Now you need to test your website to make sure everything is working normally.
- Now finally submit your sitemap to the Search engine to make sure they are aware of the changes you made in your URL.
Redirecting The URL In WordPress
After making the changes to the URL, you need to set the redirection of the old URL to the new one. This is because anyone who has the old URL can not get the error when opening the website.
Instead, the old URL is redirected to the New URL to open the website.
To redirect you can use the plugins like Redirection or Yoast SEO.
- Install the plugin and activate it.
- In the plugin settings go to Add new Redirection.
- Enter the old URL in the Source URL field and enter the new URL in the Target URL field.
- If you want to redirect the URL permanently you need to select “301 – Moved Permanently”.
- But if you want to redirect it temporarily, select “302 Found”.
- Save the change and test the redirections if they work properly or not.
Conclusion
It is always a good practice to back up your website before making any changes to it. And also to test the working of the website after making the changes.
The easier method to change URLs in my opinion is through the admin dashboard. Using plugins is also easy depending on the user’s choice and knowing how to do it right.
Hope the article will help you change the URL in WordPress as different possible methods are present in it. A step-by-step guide is present to save you from making mistakes. But if any issue arises you can ask in the comments section to get a guide from the experts.
Also, share your experience of changing URLs with the audience. Also, tell them which method you found easier for changing the URL. Thanks for visiting.