How to Change Your WordPress Site URLs (Step by Step)
Un jour, en jouant à l’apprenti sorcier, j’ai planté mon site Internet en modifiant les réglages des URLs dans WordPress.
Impossible d’accéder à mon site ! j’avais supprimé le “www.” devant mon domaine pensant résoudre un problème d’indexation… je sais c’est balo.
Je m’voyais déjà en train de tout récupérer du backup ou pire refaire mon site de zéro !
La page ci-dessous m’a sauvé plus particulièrement la méthode 4, m’a permis de reprendre la main sur mon site !
Cet article a été trouvé sur : https://www.wpbeginner.com/wp-tutorials/how-to-change-your-wordpress-site-urls-step-by-step/#wpconfigfile
WordPress Address vs Site Address
When changing WordPress site URL, you will need to update two separate settings: WordPress Address and Site Address.
This can be confusing for many beginners because they don’t know what’s the difference between the two settings.
Your WordPress Address (URL) is the address where WordPress files and folders are stored including your admin pages, media files, plugins, themes, etc.
Your Site Address (URL) in WordPress is the public facing part of your website. This is what your visitors will type in to reach your website. This is also the link that you put on your business cards.
For majority of users, the WordPress Address and Site Address URL will be the exact same link.
However in some cases, large companies may host their WordPress site on a different server because their corporate website has many other applications, and they want to isolate where each app is hosted.
But for majority of users, these two WordPress URLs need to stay the same.
That being said, let’s take a look at how to easily change WordPress site URLs. We will show you the following methods, and you can choose the one that works best for you.
- Change WordPress site URLs from admin area
- Change WordPress site URLs using functions.php file
- Change WordPress site URLs using wp-config.php file
- Change WordPress site URLs in the database using phpMyAdmin
Ready? let’s get started.
Method 1. Change WordPress Site URLs from Admin Area
This method is the easiest. If you can already access the WordPress admin area, then we recommend using this method.
Simply login to your WordPress website and go to Settings » General page. From here you can change WordPress site URLs under the ‘WordPress Address’ and ‘Site Address’ options.
WordPress Address and Site Address are usually the same address.
Don’t forget to click on the ‘Save Changes’ button to store your settings. You can now visit your website to make sure that everything is working OK.
Method 2. Change WordPress Site URLs Using functions.php File
This method is recommended for users who cannot access the admin area of their WordPress website.
Simply connect to your WordPress site using an FTP client and go to /wp-content/themes/your-theme-folder/.
From here you need to locate the functions.php file and edit it using a plain text editor like Notepad or TextEdit.
Next, you need to add the following code at the bottom:
Don’t forget to replace https://example.com with your own site URLs. You can now save your changes and upload the file back to your website hosting using FTP.
You can now visit your website to see if everything is back to normal.
The advantage of this method is that it updates the site URLs in the database. WordPress updates the database option for site URLs every time your functions file is loaded.
Once everything gets back to normal, don’t forget to remove the two lines of code from your WordPress functions file.
Method 3. Change WordPress Site URLs Using wp-config.php File
This method is only recommended if you are unsure which WordPress theme you need to edit or cannot find the functions.php file.
For this method, you will be adding the site URLs to your WordPress configuration file called wp-config.php. This file is located in the root folder of your website and contains important WordPress settings.
Simply connect to your website using an FTP client and edit the wp-config file. You need to add the following code just above the line that says ‘That’s all, stop editing! Happy publishing’.
Don’t forget to replace https://example.com with your own domain name.
You can now save your changes and upload them back to your server. After that, visit your website to make sure that everything is working fine.
Method 4. Change WordPress Site URLs in the Database Using phpMyAdmin
Another way to update WordPress site URLs is by changing them directly in your WordPress database.
First, you need to make a WordPress database backup. This step is really important and will help you undo database changes in case anything goes wrong.
After that, you need to go to your web hosting account’s dashboard and click on the phpMyAdmin icon under the Databases section.
Once you click the link, it will launch the phpMyAdmin app, which provides a web-based interface to edit MySQL databases. To learn more about it, see our guide on how to WordPress database management with phpMyAdmin
Inside phpMyAdmin interface, you need to click on your WordPress database from the left column. The app will now display tables inside your WordPress database.
Next, you need to scroll down to the options table. By default the database prefix is wp_ but since you can change WordPress database prefix, your screenshot may have a different prefix.
PhpMyAdmin will now display the rows inside the options table. You need to locate the rows where option_name is siteurl and home.
Next, click on the pencil icon on the left to edit each row and change the option_value field to the new site URL. After that, click on the tiny Go button at the bottom right corner to save your database changes.
You can now visit your website to see if everything is working fine.
Frequently Asked Questions (FAQs)
Over the years we have helped hundreds of thousands of users create a WordPress website, start a blog, or start an online store. In this time, we have answered many different questions related to changing WordPress URLs. Below are some of the most frequently asked questions.
Why are my WordPress Address and Site Address fields greyed out?
If the WordPress address (URL) is greyed out on the settings page of your admin area, then it means that the URLs are hard coded in the wp-config.php file.
To change your WordPress URL, you will need to follow method 3 in our article to edit the wp-config.php file and change the URL accordingly.
How to recover WordPress after url address change in settings?
Sometimes non-techy users can accidentally change WordPress URL and Site Address settings from the WordPress admin area. To recover from that, you will have to follow our guide above to change the WordPress URLs back using functions.php, wp-config, or the database method.