Changing domain name breaks nextcloud

Hi.
After “try” to change domain, , it’s impossible to access nextcloud, also on localhost.

There’s a nextcloud screen on the browser with a error code.
The erros are like the below, tryed to returd at initial condition / domain, but nothing change…

{"reqId":"AIMP2gYH6BddAkaDsjW8","level":3,"time":"January 25, 2022 17:25:50","remoteAddr":"XX.XX.XX.XXX","user":"--","app":"PHP","method":"GET","url":"/","message":{"Exception":"Error","Message":"ini_set(): Headers already sent. You cannot change the session module's ini settings at this time at /var/www/nextcloud/lib/base.php#402","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":402,"function":"ini_set"},{"file":"/var/www/nextcloud/lib/base.php","line":639,"function":"initSession","class":"OC","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":1076,"function":"init","class":"OC","type":"::"},{"file":"/var/www/nextcloud/index.php","line":35,"args":["/var/www/nextcloud/lib/base.php"],"function":"require_once"}],"File":"/var/www/nextcloud/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36","version":"21.0.5.1"}

Other errors, seems that Nexcloud can’t find files, but I don’t know why…

{"reqId":"SPfSyGgsoBJ10grqFmNX","level":1,"time":"January 25, 2022 18:19:11","remoteAddr":"127.0.0.1","user":"--","app":"no app in context","method":"GET","url":"/","message":{"Exception":"Symfony\\Component\\Routing\\Exception\\RouteNotFoundException","Message":"Unable to generate a URL for the named route \"photos.page.index\" as such route does not exist.","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":365,"function":"generate","class":"Symfony\\Component\\Routing\\Generator\\UrlGenerator","type":"->"},{"file":"/var/www/nextcloud/lib/private/URLGenerator.php","line":85,"function":"generate","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/nextcloud/lib/private/NavigationManager.php","line":282,"function":"linkToRoute","class":"OC\\URLGenerator","type":"->"},{"file":"/var/www/nextcloud/lib/private/NavigationManager.php","line":108,"function":"init","class":"OC\\NavigationManager","type":"->"},{"file":"/var/www/nextcloud/apps/theming/lib/ThemingDefaults.php","line":184,"function":"getAll","class":"OC\\NavigationManager","type":"->"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Defaults.php","line":263,"function":"getShortFooter","class":"OCA\\Theming\\ThemingDefaults","type":"->"},{"file":"/var/www/nextcloud/lib/public/Defaults.php","line":169,"function":"getLongFooter","class":"OC_Defaults","type":"->"},{"file":"/var/www/nextcloud/core/templates/layout.guest.php","line":55,"function":"getLongFooter","class":"OCP\\Defaults","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/Base.php","line":180,"args":["/var/www/nextcloud/core/templates/layout.guest.php"],"function":"include"},{"file":"/var/www/nextcloud/lib/private/Template/Base.php","line":150,"function":"load","class":"OC\\Template\\Base","type":"->"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Template.php","line":180,"function":"fetchPage","class":"OC\\Template\\Base","type":"->"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Template.php","line":211,"function":"fetchPage","class":"OC_Template","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/Base.php","line":132,"function":"fetchPage","class":"OC_Template","type":"->"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Template.php","line":332,"function":"printPage","class":"OC\\Template\\Base","type":"->"},{"file":"/var/www/nextcloud/lib/base.php","line":427,"function":"printExceptionErrorPage","class":"OC_Template","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":639,"function":"initSession","class":"OC","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":1076,"function":"init","class":"OC","type":"::"},{"file":"/var/www/nextcloud/index.php","line":35,"args":["/var/www/nextcloud/lib/base.php"],"function":"require_once"}],"File":"/var/www/nextcloud/3rdparty/symfony/routing/Generator/UrlGenerator.php","Line":143,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0","version":"21.0.5.1"}
{"reqId":"SPfSyGgsoBJ10grqFmNX","level":1,"time":"January 25, 2022 18:19:11","remoteA

Hi,
Did you change the ‘trusted_domains’ parameter in config.php after changing domain?

Yes, i’ve changed config.php , nextcloud.conf, and request a new certificate.

After the problem i’ve tried to go back with previous domain (and previous certificate), but the problem is not resolved.

The actual section of config is

'trusted_domains' => 

  array (

    0 => 'localhost',

    1 => 'MY-DOMAIN', 

  ),

(partially) Solved deleting config.php
Then a new login (with new admin user) by the webborwser interface, tested also with the new domain.
Some problems with the cerificate and some user access…