Moodle logout redirect not working

Re: Moodle logout redirect not working

by Leon Stringer -
Number of replies: 0
Picture of Core developers Picture of Particularly helpful Moodlers

And the authentication plugins, which ones are enabled on the site? E.g.:

Screenshot of available authentication plugins

Lines 21-28 of config.php use code to generate $CFG->wwwroot which the documentation says should not be done. Instead there should be a single line:

$CFG->wwwroot = 'https://academia.esdila.com';

If it's still not working then maybe you could add some debug output which would be sent to the web server's error log, e.g. in login/logout.php add these error_reporting() and error_log() lines:

 36 if ($login) {
37     $redirect = get_login_url();
38 } else {
39     $redirect = $CFG->wwwroot.'/';
40 }
41 error_reporting(E_ALL);
42 error_log("1: \$redirect == \"$redirect\"");
    ⋮
64 require_logout();
65
 66 error_log("2: \$redirect == \"$redirect\"");
67 redirect($redirect);

You'd then need to know where the web server error logs are (on my server they're in /var/log/php-fpm/www-error.log, yours may be different) and I get this debug output which shows that URL in $redirect is the one expected:

[07-Jan-2021 16:20:57 Europe/London] 1: $redirect == "https://moodle.example.com/"
[07-Jan-2021 16:20:57 Europe/London] 2: $redirect == "https://moodle.example.com/"

Hopefully it will help determine why the URL on your site is being changed.