Best VPS Hosting | Website Hosting Pakistan | Domain & Hosting Services

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.



Source link

Author

Write A Comment