Change the link of a siteWordPress may seem tricky, but it's vital after a site migration or a domain name change. With this guide, we will show you how to perform this operation in two simple methods directly from cPanel: by modifying the wp-config.php file or via phpMyAdmin.
Why Change Your WordPress Site URL?
There are certain situations that may arise where you need to change your site's link. Here are some scenarios that may require this change:
you are switching your site to HTTPS for enhanced security,
you are changing the domain name,
you are moving your site to a new directory or another hosting service,
you are migrating your site from a subdomain to a main domain,
or if you started developing your site locally (with WAMP, XAMPP, etc.) and want to transfer it to an online server with a new URL.
Sometimes, errors like infinite redirect loops can be related to a misconfigured URL. In this case, updating the site addresses can quickly resolve the issue.
WordPress Address and Site Address: Don't Confuse Them
Before making any changes, it's essential to understand that WordPress uses two distinct addresses, often confused:
The WordPress Address (WordPress Address / WP_HOME) corresponds to where the CMS files are stored. It’s the URL used to access your dashboard, your plugins, your media, etc.
The Site Address (Site Address / WP_SITEURL) is the address visible to your visitors — the one they type into their browser’s address bar to access your site.
In most cases, these two addresses are identical. But if you want to, for example, install WordPress in a subfolder while keeping a clean domain name upfront, you will need to configure them separately.
In the following sections, we will see the different methods to correctly modify these addresses, depending on the access you have: from the wp-config.php file, or directly in the database via phpMyAdmin.
Preliminary Step: Backup Your Site
Before you begin, it's important to keep a complete backup of your site and its database. This will help you restore your site safely in case of problems.
Cap Connect provides you with the Jetbackup5 tool to backup your data (site, email, files, databases, etc.) in cPanel following this guide: JetBackup 5: How to Backup and Restore My Hosting?
Method 1: Modify the URL in wp-config.php
If you cannot access the WordPress dashboard or the URL fields are grayed out, you can set the URLs directly via the wp-config.php file.
Here's how to do it:
Log in to cPanel, then open File Manager (or use an FTP client).
Navigate to your site's root folder.
Locate and open the wp-config.php file.
Before the line /* That’s all, stop editing! */, add this code:
define('WP_HOME', ''); define('WP_SITEURL', ''); https://votre-nouveau-domaine.com https://votre-nouveau-domaine.com
Replace "" votre-nouveau-domaine.com with your new URL.
Save the file and reload your site to ensure everything works.
Note: as long as these lines are present, you won't be able to modify the URL from the WordPress dashboard.Method 2: Change the URL via phpMyAdmin
If you prefer to modify the database directly, this method is also very simple.
Follow these steps:
From
cPanel, click on phpMyAdmin in the Databases section..
Select your WordPress database from the menu on the left.
Click on the table called wp_options (or similar, depending on the prefix).
Find the rows:
siteurl
home
Click on the Edit icon (pencil) for each, then change the value to the new URL.
Click on Go to save the changes.
Go to your site to confirm that the URL is updated.
These two fields are essential: siteurl determines the location of the WordPress files, while home indicates the main address of the site.