WebHostingPeople Blog

How Can We Help?

How to Change URL of the Joomla Website in cPanel?

You are here:

The optimal approach to Modify the URL of the Joomla Website in cPanel?

To modify the URL of the Joomla website in cPanel, we can make changes to the configuration.php file. Imagine a scenario where you want to change your domain name to a new one. You can update it in the configuration.php file. However, there are multiple URLs in the Joomla database because most of the pages are fetched from the database. In this tutorial, we will demonstrate how to change the Joomla URL.

1) Access cPanel and navigate to “File Manager”.

2) Locate the document root of the website and open the configuration.php file.

Identify the entry:

public $live_site=’olddomain_name.com’;

Replace the old domain name with the new domain name.

public $live_site=’newdomain_name.com’;

3) Save the changes.

4) Then, find the database name of your Joomla website. You can find this information in the configuration.php file.

Before modifying the database, it is recommended to take a backup of your database. In case the process fails, you can restore the database from the backup.

Alternatively, you can take a database backup through phpMyAdmin.

Login to cPanel >> DATABASES >> phpMyAdmin.

5) Select your Joomla database and click on “EXPORT” in the top menu.

6) Once the export process is completed, make a copy of the .sql file for backup purposes.

7) Open the exported file with a text editor (e.g., Notepad).

8) Find all the outdated URLs and replace them with the new ones.

9) After replacing all the URLs, save this .sql file.

10) Now, you can import this .sql file to your Joomla database.

11) Login to cPanel>>DATABASES >> phpMyAdmin.

Select your Joomla database and click on “IMPORT” in the top menu. Then, choose the .sql file that you have updated.

You may refer to the following knowledge base article for assistance in importing SQL files: https://webhostingpeople.in/tips/kb/importing-sql-file-mysql-via-command-line-phpmyadmin/


Modify URL through CLI

If you have SSH access, you can easily take a database backup by running a command. Additionally, you can change the URL using the sed command.

1) Log in to the server via SSH.

2) Run the following command to take a database backup:

mysqldump -u dbuser -p dbname > dbname.sql

3) Make a copy of the backup file:

cp -p dbname.sql dbname-bak.sql

4) Run the following command to replace the URL:

sed  -i  ‘s/orginal_entry/newentry/g’   dbname.sql

5) Run the following command to restore the new database:

mysql -u dbuser -p dbname < dbname.sql

6) If this replacement process fails, restore the old database:

mysql -u dbuser dbname < dbname-bak.sql


If you need any further assistance, please contact our support department.



Post Your Comment