There are a variety of reasons why you may either want or need to change your WordPress URLs. Two of the most common are that you’re switching your website to a new domain name or redirecting from HTTP to HTTPS.
Other reasons may be that you may be moving your content from a subdomain to a subfolder, from a subfolder/subdomain to the main domain, so on and so forth. There are many cases where you may want to change your URLs.
There are five methods you can use to change your WordPress URL. The best one to use will depend on a handful of factors, such as your experience level and whether you’re able to access your WordPress admin dashboard. In this post, we’ll discuss each option.
Before you begin
Before getting started, we recommend backing up your site. This way, in case anything goes wrong in the process of trying to change your WordPress URLs, you have a safe version of your site files to restore.
Changing WordPress site URLs from the admin dashboard
Typically, the easiest way of changing your WordPress site URLs is to go through the admin area. To get started:
- Login to your WordPress admin dashboard
- Navigate to Settings
- Select General
- Under General Settings, you’ll find two fields
- WordPress Address (URL)
- Site Address (URL)
- Change the values of these fields with the new URLs
- Click Save Changes to save
Important:
The URL should begin with “http://” or “https://” and they should match exactly.
Change WordPress site URLs using wp-config.php file
In some cases, you may not have permission to edit your site URLs via your admin dashboard. If so, you can try changing them through your wp-config.php file.
To do so:
- Connect to your site via SFTP.
- Locate your wp-config.php file from your root directory, then right-click on it and select View/Edit:
- From the file, add the following two lines with your new URL:
- define(‘WP_HOME’, ‘https://example.com’);
- define(‘WP_SITEURL’, ‘https://example.com’);
- When you’re done, click Save
Change WordPress site URLs using functions.php file
If you’re unable to access the admin area of your WordPress dashboard, another option is to change your WordPress URLs by editing your functions.php file. Again, to do this, you’ll need to connect to your site via SFTP like we covered in the above section.
- Go to your wp-content/themes folder
- Right click on the functions.php file
- Select View/Edit
- Add the following code to the bottom:
- update_option( 'siteurl', 'https://example.com' );
- update_option( 'home', 'https://example.com' );
- Replace “https://example.com” with your own URLs.
- When you’re done, save your changes.
Change WordPress site URLs in the database using phpMyAdmin
Another method you can use to change your WordPress URLs is by changing them in the database using phpMyAdmin.
To get started:
- Log into your 10Web Dashboard
- Click on Manage for the site you want to change the URL of
- Under the Hosting Services section select Credentials
- Click on Open MySQL.This will automatically log you into phpMyAdmin
- To the left side of the phpMyAdmin dashboard, you will find your WP database
- Navigate to the wp_options table
- Select the site URL and home field values, then enter the new URLs
Change WordPress site URLs using WP-CLI
The final method you can use to change your WordPress site URLs is WP-CLI. We only recommend using this method if you’re a developer or have experience using command-line tools.
To get started:
- Log into your 10Web dashboard
- Click on the website of which you want to change the URL
- Under Hosting Services, click on Credentials
- Find your SSH connection credentials and connect
- Use the following two commands to change the URL
- wp option update home 'https://example.com'
- wp option update siteurl 'https://example.com'
Important:
Make sure to press the Enter/Return key after each command. Also, remember to replace “example.com” with your own WordPress URLs.
After you enter these commands, you should be all set.