Changing the address of a Joomla site means making it answer on a new domain name without losing its content or its visitors. On your hosting, each domain has its own folder: you therefore add the new domain in the Apanel console, copy the site's files into it, adapt the configuration.php file, then redirect the old address to the new one. This article applies to Joomla 4 and 5.
In short: add the new domain with Add domain (web service set to Yes), copy the files into it, fix $log_path and $tmp_path in configuration.php while leaving $live_site empty, then redirect the old domain with a 301 in .htaccess.
Prerequisites
- The new domain name is registered, with SwissCenter or elsewhere, and points to our name servers (see Point your domain to SwissCenter), or will point to them once the site is ready.
- FTP access to your hosting (see Publish your website by FTP) or to the File explorer of the Apanel console.
- An administrator account on the Joomla site.
Before you start
- Each domain has its own folder. A domain added with its own web service gets a folder named after it, next to the old domain's folder:
/home/youraccount/new-site.ch. The site must be copied there.
- You can keep the same database. If the old domain will only redirect to the new one, the copied site can keep using the current database: there is no database to create and no connection setting to change. Create a separate database only if the two sites must each live on their own: a shared database would apply every change made on one site to the other.
configuration.php contains full paths. During installation, Joomla stores in it the path of the logs folder ($log_path) and of the temporary folder ($tmp_path), which include the name of the site's folder. After the copy, they still point to the old folder.
- Leave
$live_site empty. When it is empty, Joomla works out its address from the one used to visit it: the site works straight away on the new domain. Only fill it in if you need to, and always with the full address, https:// included.
1. Back up the site
- Export the site's database with phpMyAdmin (see Export or import a MySQL database with phpMyAdmin). Keep this file: it lets you go back.
- Download the site's folder to your computer by FTP.
If the site already uses the Akeeba Backup extension, a full backup made with it is also fine. You can also create, from the Apanel console, an archive containing the files and the database in a single file: see Back up or export your site as a downloadable archive.
2. How do I add the new domain in the Apanel console?
- Log in to your Apanel console.
- On the Dashboard, click Add domain.
- In Domain name, enter the new domain, without
www: new-site.ch.
- Leave Use DNS service enabled if the domain uses our name servers.
- In Use web service, choose Yes: the domain gets its own folder.
- In Use mail service, choose Yes if you want email addresses on this domain, otherwise No.
- Click Add.
A confirmation message is shown and the domain appears on the Dashboard. Open its Hosting management and enable its certificate in SSL security (see Install an SSL certificate on a domain).
3. Copy the files
Copy the whole content of the old domain's folder into the new domain's folder, by FTP: upload into new-site.ch the files downloaded in step 1. Do not forget the files whose name starts with a dot, such as .htaccess: some FTP programs hide them.
Do not empty the old domain's folder yet: it is needed until the new site has been checked.
4. What must change in configuration.php?
Open the configuration.php file of the new folder, with the File explorer (Tools card) or by editing it on your computer and uploading it again by FTP.
- In
$log_path and $tmp_path, replace the name of the old folder with the name of the new one:
public $log_path = '/home/youraccount/new-site.ch/administrator/logs';
public $tmp_path = '/home/youraccount/new-site.ch/tmp';
- Check
$live_site. If it contains the old address, empty it:
public $live_site = '';
- If you created a separate database for the new site (see Create a MySQL database and its user) and imported the step 1 export into it, enter it here. Otherwise, leave these lines unchanged:
public $host = 'localhost';
public $user = 'youraccount_databasename';
public $password = 'the database password';
public $db = 'youraccount_databasename';
- Save the file.
5. Do I need to replace the old address in the database?
Joomla builds its own links, but a full address typed by hand (in an article, a module, a menu or an extension) stays in the database as it is. Open the site on the new domain: if images or links still point to the old one, replace the old address in the database.
- Export the database with phpMyAdmin.
- In the resulting file, replace the old domain name with the new one: search for
old-site.ch alone, without https://, because settings stored as JSON write slashes as \/.
- Import the modified file into the database.
Some extensions store "serialized" data, where the length of each text is recorded next to it: replacing a name with one of a different length can make that data unreadable. If an extension stops working properly after the import, import the original export again and fix the links from the Joomla administration.
6. How do I redirect the old address?
Once the new site has been checked, send visitors and search engines from the old address to the new one with a permanent redirect (301). Put these lines at the top of the .htaccess file in the old domain's folder (create it if it does not exist):
RewriteEngine On
RewriteRule ^(.*)$ https://www.new-site.ch/$1 [R=301,L]
Each page of the old domain then leads to the same page on the new one. The console's Redirections management makes temporary redirects (302): for a change of domain, use .htaccess instead (see Redirect a web address to another).
Keep the old domain on your hosting for as long as the redirect must work: if it is deleted, its visitors are no longer redirected.
7. Check the site and tell Google
- Open
https://www.new-site.ch and log in to its administration (https://www.new-site.ch/administrator).
- Browse a few pages: images, internal links, forms.
- Open a page of the old domain: it must take you to the same page on the new one.
- If your site is tracked in Google Search Console, add the new domain there, then use the Change of Address tool to report the move.
Troubleshooting
| What you see |
What to do |
| "This domain already exists" when adding the domain |
The domain is already set up on a hosting account. If it is not on your Dashboard, contact support. |
| "Adding a new domain is temporarily disabled because your web quota has been reached." |
Free up space or order more (see See your disk space usage and add more), then add the domain. |
| The new domain shows the SwissCenter home page |
The files are not in the new domain's folder, or not directly at its root (see The browser always displays the SwissCenter homepage). |
| The new domain cannot be found |
The domain does not point to our servers yet, or the change has not propagated yet (see Understanding DNS propagation delay after a change). |
| The new site redirects to the old domain, or loads its styles from it |
$live_site still contains the old address: empty it (step 4). If only some images or links are affected, see step 5. |
| Joomla reports a logs folder or temporary folder that cannot be found or written to, or file uploads fail |
$log_path or $tmp_path still points to the old folder (step 4). |
| Joomla cannot connect to the database |
Compare $host, $user, $password and $db with the database's Configuration tab, in MySQL (Databases card). |
| A security warning is shown on the new domain |
Its SSL certificate is not active yet: see step 2. |
Going further