Individual Nextcloud theme per domain
May 16, 2022
If you have your Nextcloud running, you might want to run different themes on different domains, both pointing on the same Nextcloud instance. This can be done through the config.php with a few very simple steps.
What you need to keep in mind is, somehow the file gets reset if theres an update. So make a backup of your config file and copy it back again if you update your Nextcloud.
1. Open config.php from Nextcloud
Log in via SSH or your FTP client and search for this file. You might have another path:
/var/www/html/nextcloud/config/config.php
Either open it with your coding app or edit it on the server directly:
nano config.php
2. Add all necessary domains to your trusted domains to your config.php
You can do so like this:
<?php
'trusted_domains' =>
array (
0 => 'localhost',
1 => 'domain.ltd',
2 => 'cloud.domain.ltd',
),
?>
3. Add php switch for HTTP_HOST
You can add as much domains as you want. Just make sure adding all the domains always to your trusted domains. You also need to have the correct themes in your themes/ folder.
<?php
if(isset($_SERVER['HTTP_HOST'])) {
switch($_SERVER['HTTP_HOST']) {
case 'domain.ltd':
$CONFIG['theme'] = 'theme_one';
break;
case 'cloud.domain.ltd':
$CONFIG['theme'] = 'theme_two';
break;
}
}
?>
4. That's it
If all setup correctly it will load different themes as you enter the matching hostname defined in your config/config.php.