Need to change the URL of your WordPress site but don't know where to start?
Hello, my name is Javier Chiva and I work as a freelance WordPress developer.
In today's post I would like to talk about how to change or modify the url's of your website.
Whether it's a rebranding, a domain change, or simply configuration adjustments, changing the URL of your WordPress site is a task that, while it may seem daunting at first, is quite manageable if you follow the right steps.
In this article, I'll walk you through the process of how to change the URL in WordPress, making sure you can perform this essential task without hassle and keep your site running smoothly.
Preparations before changing the URL
Before we dive into the methods for changing your WordPress URL, it is crucial to make some preparations to ensure the process goes as smoothly as possible:
Make a full backup
Before making any significant changes to your site, such as updating the WordPress URL, you should perform a full backup.
This includes your WordPress files and database.
Tools such as UpdraftPlus o Jetpack Backup can make this task easier for you.
Check the compatibility of your theme and plugins
Make sure your current theme and any plugins installed will work correctly with the new URL.
If possible, check the documentation or contact the developers to confirm.
Methods to Change the WordPress URL
There are several ways to change the URL of your WordPress site, each suitable for different levels of comfort with the code and specific access to your site.
Here I explain the most common methods:
1. From the WordPress administration panel:
The easiest way to change the URL of your site is directly from your WordPress admin panel:
- Go to Settings > General.
- Here you will find the fields "WordPress Address (URL)" and "Site Address (URL)". Change these URLs to your new site address.
- Save your changes. Your site should now reflect the new URL.
This method is perfect for quick and easy changes, but if you can't access your WordPress admin, you may need to try other methods.
Continuing with the guide to changing the URL in WordPress, we will address other important methods and how to update your site after the change.
2. Edit the wp-config.php file
If you don't have access to the WordPress admin panel or prefer a method that sets the URL at the code level, you can modify the file wp-config.php
:
- Access your website via FTP or the file manager of your hosting service.
- Search for the file
wp-config.php
in the root of your WordPress installation. - Edit it by adding the following lines just before the line that says /* That's all, stop editing! Happy publishing. */
define('WP_HOME','http://tu-nueva-url.com');
define('WP_SITEURL','http://tu-nueva-url.com');
- Replace
http://tu-nueva-url.com
with your new URL. - Save the changes and upload the file if you are editing locally.
This method forces WordPress to use the newly specified URL, which is especially useful if you are having trouble accessing the administration area.
3. Use phpMyAdmin:
For more direct control, especially if the other methods are not viable, you can change the URL directly in the WordPress database via phpMyAdmin:
- Access phpMyAdmin from your hosting control panel.
- Select the database for your WordPress site.
- Search the table
wp_options
(the prefixwp_
may vary depending on your installation). - Locate tickets
siteurl
yhome
. Click the edit icon for each and change the value to your new URL. - Save your changes.
This method changes the URL at the database level, making the change immediately. It is vital to ensure that you enter the correct URL to avoid access problems.
Update internal links and content
After changing the URL of your site, it is essential to update the internal links and references to the old URL in your content:
- Use a plugin like "Better Search Replace" which allows you to search and replace strings in your database, ideal for updating URLs in bulk.
- Perform a search for your old URL and replace it with the new one in all content and settings.
Post-URL change settings
Once the URL change is complete, make these adjustments to ensure the proper functioning and SEO of your site:
Update Google Search Console and other SEO tools: Inform Google and other search engines about the URL change to preserve your ranking.
Configure 301 Redirects: Set up permanent redirects from the old URL to the new URL to avoid 404 errors and transfer SEO authority.
Check the site: Navigate your site to make sure everything is working properly, including contact forms, third-party integrations, and RSS feeds.
Troubleshooting common problems
If you encounter problems after the URL change, consider these solutions:
- Database Connection Errors: Verify that URLs in
wp-config.php
and the database are correct. - Redirection problems: Make sure 301 redirects are correctly configured. Check and adjust the
.htaccess
if necessary. - Restore from Backup: If all else fails, consider restoring your site from the backup made before the change.