Fix “This webpage has a redirect loop” Moodle v2.7

Moodle v2.7 installation gives “this webpage has a redirect loop” error. 

The Problem

Extracts from Apache access log /var/log/apache2/access.log:

[...] "GET /admin/index.php?sessionstarted=1&lang=en HTTP/1.1" 303 903 
[...] "GET /admin/index.php?cache=1 HTTP/1.1" 303 941 
[...] "GET /admin/index.php?sessionstarted=1&lang=en HTTP/1.1" 303 903 
[...] "GET /admin/index.php?cache=1 HTTP/1.1" 303 941
[...] "GET /admin/index.php?sessionstarted=1&lang=en HTTP/1.1" 303 903
[...] "GET /admin/index.php?cache=1 HTTP/1.1" 303 941

The Fix (Ubuntu 14.04 with Apache2)

Find out the moodle dataroot directory:

# grep ">dataroot.*=" /var/www/html/moodle/config.php
$CFG->dataroot  = '/var/lib/moodle-data';

And remove all content:

# rm /var/lib/moodle-data/* -Rf

Reload a web-browser.

19 thoughts on “Fix “This webpage has a redirect loop” Moodle v2.7

    • I never got to the bottom of this problem, but as dataroot contained “cache”, “localcache”, “session” and “temp” directories, this must have been something related with the server’s cache.

  1. $CFG->dataroot contains both cache and uploaded files. Deleting the whole content of the data directory could be a bit too aggressive.

  2. Obrigado.
    Funcionou no meu moodle, já tinha tentado várias coisas sem sucesso, inclusive debugar o codigo, ele entrava em loop e eu não conseguia solucionar. Mas sua solução resolveu.

    Thank you.
    Worked on my moodle, had already tried several things without success, including debug the code, it went into loop and I could not solve. But your solution solved.

  3. Pingback: ‘This webpage has a redirect loop’ or ‘The page isn’t redirecting properly’ with fresh installation | Moodle World

Leave a Reply

Your email address will not be published. Required fields are marked *