This guide explains how to properly change your WordPress website from one domain name to another on cPanel hosting.
Following the steps in the correct order is very important to avoid website accessibility issues.
Before You Start
Make sure you have the following:
- Access to your hosting cPanel
- Your new domain name already registered and pointed to your hosting
- Basic familiarity with the cPanel interface
How to Access cPanel
You can access cPanel using one of the following methods:
- Log in through the Client Area:
https://my.libyanspider.com - Direct cPanel login:
https://yourdomain.com/cpanel
Replace yourdomain.com with your current active domain name.
Step 1: Update WordPress to Use the New Domain
You can do this using one of the following methods.
Method 1: Update the Domain from phpMyAdmin
Access phpMyAdmin
- Log in to cPanel.
- Scroll to the Databases section.
- Click phpMyAdmin.
Select Your WordPress Database
- In the left sidebar, select your WordPress database.
- Locate the table named
wp_options.
Note: Your table prefix may be different, such as wp123_options.
Edit the Website URLs
- Open the
wp_optionstable. - Look for the rows with the following
option_namevalues:siteurlhome
- For each row:
- Click Edit
- Change the
option_valuefrom the old domain to the new domain
Example:
- Old:
https://olddomain.com - New:
https://newdomain.com
- Click Go to save the changes.
Verify the Changes
Confirm that both siteurl and home now contain the new domain name.
Method 2: Update the Domain from wp-config.php
This method is useful when you cannot access the WordPress admin area or want to force WordPress to use the new domain.
Access File Manager
- Log in to cPanel.
- Scroll to the Files section.
- Click File Manager.
- Open your website’s root folder, usually
public_html.
Edit the wp-config.php File
- Locate the file named
wp-config.php. - Right-click it and choose Edit.
- Find this line:
/* That's all, stop editing! Happy publishing. */
- Add the following lines above that line:
define('WP_HOME','https://yournewdomain.com');
define('WP_SITEURL','https://yournewdomain.com');
- Replace
yournewdomain.comwith your actual new domain name.
Save the File
- Click Save Changes.
- Close the file editor.
Step 2: Configure the New Domain in cPanel
After updating WordPress, configure the new domain in cPanel.
You have two options.
Option 1: Add the New Domain in cPanel
This is the recommended option.
- In cPanel, go to Domains.
- Click Create A New Domain.
- Enter your new domain name.
- Set the Document Root to the same location used by your current website, usually
public_html. - Click Submit.
This method allows both the old and new domains to work during the transition period.
Option 2: Change the Main cPanel Domain
This step is optional and may require assistance from support.
If you want to replace the main cPanel domain with the new one, open a support ticket through the Client Area and provide the following:
- Your current main domain
- The new domain you want to use
- Confirmation that WordPress has already been updated to the new domain
Client Area: https://my.libyanspider.com
In most cases, adding the new domain is enough and is easier to manage.
Step 3: Test Your Website
After completing the changes:
- Clear your browser cache.
- Visit your new domain name.
- Check that the website loads correctly.
- Test the WordPress admin area at:
Troubleshooting
If your website still redirects to the old domain:
The Website Still Redirects to the Old Domain
- Make sure you updated WordPress before making domain changes in cPanel
- Verify that both
siteurlandhomewere updated correctly - If using
wp-config.php, confirm the domain entries are correct and includehttps:// - Clear your browser cache and cookies
- Clear any WordPress caching plugins if enabled
You Cannot Access the WordPress Admin Area
If you are unable to log in to /wp-admin:
- Use the
wp-config.phpmethod to force WordPress to use the new domain - Double-check the domain format for accuracy
- Make sure the new domain is correctly pointed to your hosting account
Some Links or Images Still Use the Old Domain
After changing the domain, you may still need to:
- Update hardcoded links inside pages or posts
- Update widget settings that contain the old domain
- Regenerate permalinks from Settings > Permalinks in WordPress
Summary
To safely change your WordPress domain name on cPanel hosting:
- First: Update WordPress to use the new domain through phpMyAdmin or
wp-config.php - Second: Add the new domain in cPanel, or request a main domain change if needed
- Finally: Test the website and update any remaining references to the old domain
Following this order helps prevent redirect problems and keeps your website accessible during the transition.