Bobcares

Fix redirect loop in Moodle easily

by | Jun 13, 2020

Moodle is a widely used learning platform. As with any other software, Moodle also has it’s share of bugs and errors. The redirect loop in Moodle is one among them.

Third-party plugin settings, the permission of the session folder, etc are a few of the common reasons that trigger the redirect loop.

As a part of our Server Management Services, we help webmasters, web hosts and online service providers to fix similar Moodle errors routinely.

Today let’s get into top reasons and fixes for the redirect loop error.

 

What causes redirect loop in Moodle

Users often receive a Redirect loop on a fresh Moodle installation. This could be a result of an entry in index.php file of the admin folder or an issue with cache/ session folders in the moodledata directory. To list out, some of the reasons that trigger the error include:

  • Redirect code in index.php
  • Cache and Session files
  • Permission of the session directory
  • Error with third-party plugins
  • Browser cookies

 

Redirect code in index.php

The most common reason for the redirect loop is a redirect code in the index.php file for the admin folder. The first step to fix this code is to identify the local directory folder of the Moodle installation. Then, navigate to Admin folder and open the index.php file.  Once the index.php file is opened, comment out the following line and then save the file.

//redirect(“index.php?sessionstarted=1&lang=$CFG->lang”);

 

After commenting the redirect code, finally, we delete the session files from the access > sessions folder inside the moodledata folder. This should fix the moodle redirect loop.

 

Cache and Session file issues

At times the redirect loop in Moodle can be just a glitch caused by cache or session files. We just need to clear the cache and session files to make the website load again.

These files are placed in the moodle data root directory. We can find the exact location of the data root directory from the moodle configuration file.

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

where /var/www/html/moodle is the installation path for Moodle. It may vary for each installation.

Some people advice to delete the entire contents of the dataroot. But it may result in data loss. Thus the safest and preferred method would be to delete only the cache and session files from this folder.

 

Permission of the session directory

Each time we access a Moodle website, a session file is automatically created in the background. The sessions folder in the dataroot should have the write permission to perform this task.

The recommended permissions for the files and folders in moodle is 755 on directories, 644 on files. Therefore, Correcting the permissions will fix the issue in most cases.

 

Error with third-party plugins

Many a time the third party plugin installed may cause conflicts with the Moodle installation. We handled a similar support request recently. One of the plugins had a require_login(); provided in its code which was triggering a redirect loop while accessing the home page of the website.

In such situations, enabling the debug mode will help our Support Engineers to gather more details.

For this, we,

  1. Log in to Moodle.
  2. Navigate to Site admnistration>>Development>>Debugging.
  3. Enable the checkbox ‘Display debug messages’.
  4. Finally, choose the option ‘ALL: Show all reasonable PHP debug messages’ from the drop-down at ‘Debug messages’.

 

redirect loop in Moodle

Browser Cookies

At times the redirect loop error in Moodle could be just a glitch that the browser cookies trigger. Thus it is not a bad idea to try clearing the browser cache to fix the error

[ Need help in fixing redirect loop in Moodle – We will fix it for you ]

 

Conclusion

In short, the redirect loop error in Moodle makes the home page inaccessible and at times displays the message “The page isn’t redirecting properly”. Third-party plugin settings, the permission of the session folder, etc are a few of the common reasons that trigger the redirect loop. Today we discussed the top reasons for this error and how our Support Engineers fix it.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF