How to change WordPress URL and why would you want to do that?
A WordPress site URL is automatically created when you create a new page. Since WordPress uses the titles to create WordPress URLs, you will often end up with a WordPress URL that you actually wanted. However, if you are not happy with the site URL, you can easily change it and today we are going to teach you how to do it.
There are many reasons why one wants to change WordPress URL. You can change URL to optimize it for search engines, to make it simpler and memorable etc. We will talk some more about the reasons why you’d want to do that a little bit later.
So how to change a WordPress URL? It only takes a few simple steps:
- Login to WordPress
- Open the existing page or create a new page
- Enter a Title if necessary
- Save the page, this will automatically create a URL
- Look directly under the title field, you will see Permalink: followed by the URL
- Click the Edit button behind the link
- Type in the new URL and click OK
- Save the page or post
What? You didn’t get here to find out how to change a page’s URL? Good, we’re going to cover that in the rest of the article.
There are some effective methods and we will touch on them in a moment.
But first, let’s cover the common reasons why you would change the WordPress domain.
Why should I change the WordPress address (URL)?
You might want to WordPress change site URL for many reasons. Below are some of the common cases.
Case #1 — Moving from a subdirectory
The first case is when a WordPress site moves from a sub-directory to its parent domain. For example:
- Move from http://example.com/blog to http://example.com
Case #2 — Adding or removing www
In some cases, you will want to change URL WordPress if you need to remove www or add it to the domain.
In cases like this, there is a chance an error will occur and you will see “Too many redirects” or “The page isn’t redirecting properly” on your website.
Case #3 — Adding https to the URL
If you’re using an SSL certificate, the first part of the URL changes from ‘http’ to ‘https’.
Case #4 — Moving to a new domain
WordPress changing domain is also required when a site moves from one fully hosted domain to a different one. For example:
- Move from http://example.com to http://wpdatatables.com
How to change URL on WordPress: the methods
There are several ways of changing WordPress URL. So let’s see how to change a WordPress domain.
Note: When you decide to WordPress change domain name, be careful to edit the values correctly to avoid bringing the whole site down.
Change WordPress URL in Admin Dashboard
This is the most common method to change WordPress domain in admin dashboard. On the left-hand side, under “Settings,” click into “General.” You can then update the following:
- WordPress Address (URL): The address to reach your blog.
- Site Address (URL): The address of your WordPress core files.
If you are not giving WordPress its own directory, both of these should match. Keep in mind that once you save the changes, you will be able to access the dashboard via the new URL only.
To avoid receiving a redirect error, clear your WordPress cache when you change WordPress URL in database.
Note: If the fields above are grayed out, it is most likely because you already have hard-coded values in your wp-config.php file. If that is the case, proceed to the following method:
Change the WordPress URL in wp-config.php File
If you want to edit WordPress home URL, you can also do it via your wp-config.php file. Keep in mind that values in wp-config.php override the settings in method one. If the fields are not editable, they are probably hard-coded in this file.
The wp-config.php file is typically located at the root of your WordPress site and can be accessed via FTP, SSH, or WP-CLI. To hard-code WP_HOME and WP_SITEURL, simply input the following code towards the top of the file, changing the values to reflect your domain.
How to change the URL directly in the database
You can change WordPress domain name directly in database using phpMyAdmin which you can access through your dashboard in cPanel or Plesk. However, this method should not be your first choice and it should only be done if the first two methods don’t work for you.
Keep in mind that manipulating and changing tables directly from phpMyAdmin could break your site if not done correctly. If you have no experience changing WordPress domain from the database, you should probably consult a developer first. And speaking of tables, check out wpDataTables for options on managing your front-end WordPress tables.
If you are determined to edit the WordPress address URL this way, click on your database on the left-hand side in phpMyAdmin. Click on the wp_options table and then you will be able to change both the values for the “siteurl” and “home” rows.
Enter your domain (URL) and click “Go.” Keep in mind that from this point on, your WordPress dashboard will only be accessible via the new URL.
Change WordPress URL with WP-CLI
The least recommended way to change site URL WordPress is directly with WP-CLI. This is not to be done unless you are a developer. If you are not familiar with WP-CLI, you can find out more in our in-depth post on managing WordPress from the terminal.
Here is an example of the command to update your WordPress URL values:
wp option update home ‘http://example.com’
wp option update siteurl ‘http://example.com’
Sometimes when you move your website from one location to another, you have to manually edit the data in the database to ensure that the new site.URL get recognized properly.
However, keep in mind that there are many tools out there that can help you with this and it is safer to use one of them than to modify WP site URL manually.
Altering Table Prefixes
A great number of WP administrators run several WordPress installations off of one database using various wp-config.php hacks. These hacks often involve dynamically setting table prefixes. That being said, if you alter your table prefix, you must update several entries within the prefix_usermeta table as well.
Don’t forget to back up your database first because the SQL changes are permanent. Remember to alter the table prefix in the usermeta tables if you are changing table prefixes for a site. This will allow the new site to properly recognize user permissions from the old site.
Changing the Config file
If your database has moved or changed in certain ways, you will need to update the WP configuration file.
You don’t have to do this unless:
- your database has moved to another server and is not running on your localhost
- you have renamed your database
- you have changed the database username
So here is what you have to do:
- Make a backup copy of your wp-config.php file.
- Open the wp-config.php file in a text editor.
- Review its contents. In particular, you are looking for the database host entry.
- Save the file
Once all these steps have been completed, your site should be working just fine.
Ending thoughts on how to change the WordPress URL
Can I change my WordPress URL? Yes, you can and there are numerous reasons to do this.
In this article, we explained how to change your WordPress URL and why and we pointed out some details to keep in mind when trying to WP config site URL.
As long as you follow our little manual, you should be able to change domain WordPress quickly and easily.
If you enjoyed reading this article about how to change the WordPress URL, you should also read these:
- Best WordPress Download Manager Plugins
- WordPress migration plugin options to move your website
- 12 Tips for Creating a Successful WordPress Premium Plugin or Theme