Site not accessible after installation "Redirect Loop" (New Installation)

Site not accessible after installation "Redirect Loop" (New Installation)

by G R -
Number of replies: 52

I recently installed Moodle Version 2.5 (New Install) on a Linux/Apache server running PHP 5.4 and MySQL Version 5.167.

The installation process was completed without a hitch.  However, after configuring the admin user through the supplied wizard the site is no longer accessible.  When I try to launch the site in Chrome I get the following prompt "The webpage has a redirect loop".

I can access the site by going to the moodle/course/, however, after clicking on Login url I am forward to "/admin/index.php?sessionstarted=1&lang=en" and the "This webpage has a redirect loop" is returned.

I have tried connecting in multiple browsers on multiple OS's with no luck.

Thanks for taking a look.

Average of ratings: -
In reply to G R

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Ken Task -
Picture of Particularly helpful Moodlers

Check apache error logs for clues.

Edit config.php file adding the following to put it into debug mode:

// Force a debugging mode regardless the settings in the site administration
// @error_reporting(E_ALL | E_STRICT);
// @ini_set('display_errors', '1');
// $CFG->debug = (E_ALL | E_STRICT);
// $CFG->debugdisplay = 1;

Uncomment the lines above with exception of the first line to make them active.

Then hit the site and copy and paste the output into a text editor (NotePad/TextEdit) to share back here.

'spirit of sharing', Ken

Average of ratings:Useful (1)
In reply to Ken Task

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by G R -

Hello Ken,

Unfortunately this is on a shared hosting platform and I do not have access to the apache error logs.

I added the lines you suggested above and commented out all but the first line.  No errors were returned and I still receive the same error from the browser.

In reply to G R

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Ken Task -
Picture of Particularly helpful Moodlers

Is Moodle being installed by a script provided by the hosting company (the 'wizard' that you refer to) where you fill out admin account information in a form prior to the installation.  If so, it ain't so wizardry is it!!!!  And what does the hosting company say about that?

Is this true for any browser, or just chrome?  There are others who have similar issue with Chrome but with other apps.  So clear your browser cache and cookies for all sites.  Then try again.  Have you tried other browsers? 

Sounds as if the installation cannot initialize a session.   If that still happens, let's try and change how Moodle records sessions.   Sessions, by default, are recorded to the DB.  Can change that behavior via config.php adding:

$CFG->dbsessions='0';

Upon the first attempt at logging on, Moodle should be able to create a 'sessions' folder in the moodledata folder (whatever you called that) and the session information is recorded there.

'spirit of sharing', Ken

In reply to Ken Task

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by G R -

Moodle was installed using the install files downloaded from the Moodle.org website.

The errors can be reproduced in multiple browsers on multiple clients both pre and post cache and cookies clearing.

$CFG ->dbsessions='0' was added to the config.php file in the root directory.  I am now getting the following PHP errors:

Notice: Use of undefined constant __DIR__ - assumed '__DIR__' in /my/moodle/installation/lib/dml/moodle_database.php on line 27

Warning: require_once(__DIR__/database_column_info.php) [function.require-once]: failed to open stream: No such file or directory in /my/moodle/installation/lib/dml/moodle_database.php on line 27

Fatal error: require_once() [function.require]: Failed opening required '__DIR__/database_column_info.php' (include_path='/my/moodle/installation/lib/zend:/my/moodle/installation/lib/pear:.:/usr/lib/php5') in /my/moodle/installation/lib/dml/moodle_database.php on line 27

I have confirmed that both files exist in the "dml" directory.

In reply to G R

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by G R -

The wizard I referred to earlier is the one presented by moodle during setup.  It asks you to configure the credentials and profile for the admin user.

I overwrite the moodle_database.php and database_column_info.php files and while I no longer have PHP errors the redirect issue has returned.

It still tries to go to "admin/index.php?sessionstarted=1&lang=en" is it normal behavior for it to go to /admin when I haven't even attempted a logon?

 

Here is what my config.php file looks like.  Just want to make sure I am placing the $CFG->dbsessions='0' in the appropriate spot.

<?php // Moodle configuration file

 

unset($CFG);
global $CFG;
$CFG = new stdClass();


$CFG->dbtype = 'mysqli';
$CFG->dblibrary = 'native';
$CFG->dbhost = '****************';;
$CFG->dbname = '****************';
$CFG->dbuser = '****************';
$CFG->dbpass = '****************';
$CFG->prefix = 'mdl_';
$CFG->dboptions = array (
'dbpersist' => 0,
'dbsocket' => 0,
);

$CFG->wwwroot = '*****************;';
$CFG->dataroot = '*******************/moodledata';
$CFG->admin = 'admin';

$CFG->directorypermissions = 0777;
$CFG->dbsessions='0';
require_once(dirname(__FILE__) . '/lib/setup.php');

// There is no php closing tag in this file,
// it is intentional because it prevents trailing whitespace problems!

 

In reply to G R

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Ken Task -
Picture of Particularly helpful Moodlers

According to what I can find concerning that error and the fact this is on a shared host, am wondering if the instance is pointed to a php version that supports 2.5.  Remotely hosted systems might be running multiple versions of PHP and one has to point the higher version.  Reason am thinking that ... /usr/lib/php5.  That php5 might be a version 5.2 and not the required 5.3.x+

Please see:

http://www.inmotionhosting.com/support/edu/moodle/errors-unicode-database-undefined-constant

Create a phpinfo page and drop it in the root of the new install.  Call the page info.php and it's contents look like:

<?php
phpinfo();
?>

Then hit the site with browser pointing directly at the info.php file: http://yoursite/yoursubdirectories/info.php

How to point to the required PHP is a question to ask your provider.

'spirit of sharing', Ken

In reply to Ken Task

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by G R -
PHP Version 5.4.15
In reply to G R

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Ken Task -
Picture of Particularly helpful Moodlers

Was the bolded 'shout' of php version taken from phpinfo or just a reminder that's what the php version is ... period ... remote hosting provider has only that version available to it's customers (which would be, I think, unusual).

There have been others with issues installing 2.5.0 Maybe the solution is for you to get the latest build of that version and try it again.

Who is your provider?  They offer no assistance on their shared systems?  They have no FAQ's or KB that others could view?

'spirit of sharing', Ken

 

In reply to Ken Task

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Ken Task -
Picture of Particularly helpful Moodlers

One last suggestion ...

Go directory to: http://yoursite/subdir/admin/purgecaches.php

It should prompt you to login first and then redirect to a page that has a button to purge all caches.

Am at the end of rope here (since the hosting provider unknown).  Can't do any sluething for ya without such info.

Best of luck!

'spirit of sharing', Ken

In reply to Ken Task

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by romano gino -

The last sugesttion worked for me smile 

but with a modification: http://yoursite/admin/purgecaches.php

Thanks.

r.

In reply to Ken Task

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Robert Brenstein -
Moodle does not do any redirections, so there must be something funky in the apache, htaccess, and/or dns configs. May be a combination of things.

If you could install using uploaded files, yu must have access to cpanel or something similar. Your provider can let you see server logs there. If not ask them to extract these for you for a specific time period when you know you generated those errors.
Average of ratings:Useful (2)
In reply to Robert Brenstein

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Sergey Cleftsow -

I have the same problem on two different LOCAL computers. It's moodle, not Apace etc. I have some other project on my PC and have no problem with them. I very surprised.

In reply to Robert Brenstein

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Zhijun Zhang -

I think this is Moodle's problem. I have ATutor installed without any problem in  the same environment. Just confirm this problem happened to me also. 

In reply to Zhijun Zhang

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Damyon Wiese -
I saw this today too. I fixed it by deletingvthe moodledata/cache folder on the server.
Average of ratings:Useful (13)
In reply to Damyon Wiese

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Shreyas Rao -

Thank you Damyon Wiese. After a lot of searching on the web, I came across your solution and gave it a shot. It worked like a charm!!! Thanks again!!

In reply to Damyon Wiese

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Ritesh Wadhwani -

Damyon you are super genius. 

I just installed moodle and haven't yet linked it to my website. Soon after installation I started getting the error. Your solution worked.

Thank you

Ritesh


PS: There are few other solutions at the end of these videos on youtube




In reply to Damyon Wiese

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Chris Young -

Damyon you are a Genius! Thank you so much for your simple solution. Wasted so much time with other ideas. Wonder why this is necessary?

In reply to Damyon Wiese

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Krithika Kartik -

great! This solution worked for me as well.

 

Thanks a lot for sharig

Krithika Kartik

In reply to Damyon Wiese

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Sumit Negi -
Hi Damyon,


Thanks for this useful information, it really helps me. 

In reply to Damyon Wiese

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Tshering Wangchen -
Thank you, Damyon. Worked like a charm!
In reply to Damyon Wiese

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by jigar patel -

You saved my day !! Thanks !! 

In reply to Ken Task

problem while binding website

by pallavi kapase -

hi sir,

we are implementing moodle on our local machine(windows) and we have done all previous  process sucessfully but we recieve  problem in it . our problem is Data directory (C:\inetpub\wwwroot\moodledata) cannot be created by the installer. 

please give us solution as early as possible.

In reply to G R

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

I really cannot help you much.  What I want to add is that I have (experimental) Moodle's installed on three different hosted server systems, and they all work.  However, I did have to make sure that the basic requirements of Moodle were met, meaning up to date php and mySQL, and all of the required php directives turned on.   Having said this, there are still many ways to install, and versions of all of these php modules that when Moodle doesn't behave, it is not real surprising to me.  I am not a system administrator, but somehow manage to get my moodle's working.

Ken's advice is always great, and I respect his knowledge.  But I have never had to do any of the things that he has suggested to you in my own installs.

Here's a few (simple) ideas for you.  Have you set the database collation to utf8_unicode_ci?

Consider comparing the results of php.info on your system to that of other successful installs.  Look for differences, especially required modules and php settings.  This will take awhile.

My "production moodle" system is as follows: Moodle 2.6.3 (Build: 20140512), PHP Version 5.5.7, MySQL 5.5.34, CENTOS 6.4, Apache 2.2.26.  This is a GoDaddy "Value" VPS.  I have around 6 experimental installs also working.  Right now, on one of my installs I get a "Redirect Loop" because I just converted from a raw IP address to a domain name, but my server does the redirection just fine.  I am going to fix this by editing my config.php file, redoing the URL on the few lines.  Prior to assigning a domain name to the IP, this install of moodle was working fine.

Hope some of this helps.


In reply to Ken Task

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Soumyajit Mandal -

Hi Everybody,

I am quite new to moodle and trying to install moodle version 2.8.3+ (Build: 20150219) as of moodle installation directory version.php on xampp windows. I have  successfully deployed previous version of moodle in like 2.5, 2.6 into LAMP as well in XAMPP. But in this time I am getting error after performing the admin username, password, email, timezon etc inputs. It is taking me to   http://localhost:5050/moodle/admin/index.php?cache=1 page and browser shows me "Firefox has detected that the server is redirecting the request for this address in a way that will never complete" and  " This problem can sometimes be caused by disabling or refusing to accept cookies." I was following this post and found the suggestion that I should delete the folder cache into the moodledata folder. But no folder had been created in such name. I assume the moodledata is the name of my moodle installation directory so I worked accordingly and found cache directory in it. Deleting this directory giving me "Fatal Error".  So I assume that cache folder is essential for moodle since it has some lib.php.  

Now as I stated the problem clearly can anybody suggest me any solution which will work for me. 

Thanks

Soumyajit

In reply to G R

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Matt Rice -

Have you ruled out the usual suspects? Cookies/cache/etc.?

I have a similar issue crop up occasionally because I have my Chrome set to block cookies by deafult; certain sites don't work correctly with cookies blocked (they will through a "Redirect loop error" and allowing those sites to set their cookies properly solves the issue.

In reply to Matt Rice

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Matt Day -

I have reinstalled 2.5 now 3 times, each time the install goes fine as per the OP, and once I do the profile update bam i get a redirect loop error.

This is an absolute clean install using moodle's supplied webinstall.

In reply to Matt Day

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Matt Day -

Just as an FYI I did a downgrade install of 2.4.4+ and it installs perfectly fine no looping but both 2.5 and 2.5+ give me the loop of death.

In reply to Matt Day

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Deborah Davidson -

I too have installed Moodle today, using all the updates during installation and everything was fine and I managed to create an admin account.  Since then  I've cleared cookes, caches and history but am still stuck in a "repeated loop".  I've used a hosting company for the data base and everything was successful until I tried to log-in again.  I don't have much programming experience so basic instructions/help would be very much appreciated.

In reply to Matt Day

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by madhuniha g -

Hi Matt,

Did you get  moodle running finally? I am struggling with same problem for redirecting..

 

Thanks,

 

In reply to madhuniha g

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Olami Jolaiya -

Hi everyone, how did you guys resolve the redirection problem, i have similar problem after a smooth install. I had logged on to several machines and also used several browsers and still no luck. I installed v2.5 on php 5.3. installation was cool but now i can't access the home page any longer. I can give you guys access to my cpanel through teamviewer or some other remote tool so we can check it together. thank you.

Just a little note, my installation was done on a subdomain, maybe that might put a little light into what is happening, my hosting company is ixwebhosting and the tech guys are wonderful. they gave me all the necessary support, but we could not get to the root.

In reply to Olami Jolaiya

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Eric Greene -

Hi.  I am having the same problem...  Anyone have a solution yet?

In reply to Eric Greene

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Ken Task -
Picture of Particularly helpful Moodlers

@ all ...

I've had this happen but only a couple of times.  When something like that happens, have found it's best NOT to panic and close down the browser, but, rather, use the URL line of the browser and erase the ending of the URL up to admin/ (right to left).  Hit enter key and found Moodle was attempting to direct me to some setting screen.   Saved.  And everything ok after good.

Have had to do this once on a stubborn server ...

http://server/admin/purgecaches.php

and it continued so physically removed the contents of:

/moodledata/cache/cachestore_file/default_application

which is what the purgecaches.php script was to do.

At that point, cleared the browser cookies and cache.

Then attempted to login again.  Finally, success.

One cravat ... none of the servers I work on are on shared hosting (cheapo plan).

'spirit of sharing', Ken

 

Average of ratings:Useful (4)
In reply to Ken Task

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Eric Greene -

Thanks Ken!

Deleting the cache from the command line worked perfectly.  I can login!

Average of ratings:Useful (1)
In reply to Eric Greene

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Ken Task -
Picture of Particularly helpful Moodlers

Good!  Glad to hear it. 

Forgot to mention how to build up those cache files in one action ... Site Admin Menu, Search for 'cache'.  That will bring up a page that list all items related to cache.   Change nothing ... scroll to the very bottom of the page and click Save.  Behavior is such that it appears to take some time ... that's a good sign ... once these cache files are built back up things should be 'normal' ... whatever that is! :|

'spirit of sharing', Ken

Average of ratings:Useful (1)
In reply to Ken Task

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Eric Lubega -

Thanks Ken,

This worked for me.

In reply to Ken Task

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Grace Urvantsev -

Ken,

Thanks so much it works.  I am new to Moodle and I installed Moodle 2.6+ today.  The installation went well but it kept redirecting after I tried to log in.  I read your suggestion and it works. 

Grace

 

In reply to Grace Urvantsev

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Grace Urvantsev -

Ken,

Here is a question for you.  I do not know PHP that much and I was wondering if the files that we deleted from the /moodledata/cache/cachestore_file/default_application would affect the application in anyway?

 

Grace

 

In reply to Grace Urvantsev

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Ken Task -
Picture of Particularly helpful Moodlers

At first it might make things slow, but eventually that entire folder should be rebuilt with new cache ... at least that's what I've found.    Suggest logging on and clicking through the admin menu for blocks/mods/themes, etc.   After clicking on say blocks ... check the default_application folder to see if there is something new ... ie, been re-cached.

'spirit of sharing', Ken

In reply to Ken Task

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Zhijun Zhang -

This works for me also.

In reply to Ken Task

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Chris Collman -

Hi all,

I followed Ken's instructions and got my Moodle 3.0 up and running.  

I set up an XAMPP server and put Moodle 3.0 in ../htdocs/Moodle30.   I got the "Firefox has detected that the server is redirecting the request for this address in a way that will never complete" screen.  Something similar with E. At first I thought it might be a mySQL problem so I put in the port and socket in Moodle's config.php.  

What worked was to physically delete the

../moodledata/cache/cachestore_file/default_application folder.  

I put this wonderful solution into MoodleDocs under XAMPP.  

Note: I had Bitnami install a version of 2.3 on the same XAMPP server two weeks ago.   It put Moodle in ../apps/moodle/htdocs and worked just fine. 

Thank you Ken for the magic wand and for everyone else for asking the question.

Chris

In reply to G R

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by radu chis -

Hi guys,

Usually the loop redirect occurs when the data root is not correctly setup and apache does not have writing permissions on it.

CFG->dataroot  = 'make sure this is setup correctly in config.php'

In reply to radu chis

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Julian Davis -

That turned out to my issue, thanks for the tip!

Julian

In reply to G R

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Chris Stowe -

My fix for this issue was to increase the php memory_limit

 

http://wiki.phpgedview.net/en/index.php/Configure_memory_usage_for_php

 

I am working with cpanel and a fresh install of 2.6

 

Hope this helps some people as i spent two days looking for fixes.

 

Cheers

Chris.

Average of ratings:Useful (1)
In reply to Chris Stowe

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by john owen-jones -

just had the redirect problem with moodle 2.6 i think it has something to do with caching in moodledata.

we had a moodle install of 1.9 on our hosted server in a subdomain no less. But rather than upgrade from that decided to start fresh with 2.6 which is what I set up on a test machine on 64 bit debian.

Rather than just delete the old site I renamed moodledata moodledata.old and created new empty folders for the fresh install.  first go round i gave the database tables a prefix of mdl2.6_ instead of mdl_ in the end I went into the database with phpadmin and dropped all the tables rather than keep the old ones.

Anyway first go round got the redirect loop after installing into web I looked at our sister site and saw it was in web/moodle  so I thought maybe that was the problem and ftp'd the install files again.

still ended up with the redirect loop.  so after a little googling I found there might be an issue with a folder in moodledata well that folder was there same permissions as on our sister site.  So i decided  to take a chance and called moodledata moodledata.new and renamed moodledata.old back to moodledata, after all i figured the worst is another reinstall or maybe just a rename again.

well surprise surprise the new 2.6 site came straight up  no problems i was able to log in and make some basic changes. Now there seems to be just the difference that the old moodledata folder already had cache folders 1 - 256 (most numbers) i seen a post about doing something to rebuild the cache but its a bit difficult if you can't log in the site. I think its a hosted system problem because my test server had no issues at all with the install.

In reply to john owen-jones

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Tharun Kumar -

Hi Guys,

I Followed KEN details that to delete files from C:\xampp\moodledata\cache\cachestore_file\default_application,

after done this my site is working well..

In reply to Tharun Kumar

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Soumyajit Mandal -

Hi Everybody,

I am quite new to moodle and trying to install moodle version 2.8.3+ (Build: 20150219) as of moodle installation directory version.php on xampp windows. I have  successfully deployed previous version of moodle in like 2.5, 2.6 into LAMP as well in XAMPP. But in this time I am getting error after performing the admin username, password, email, timezon etc inputs. It is taking me to   http://localhost:5050/moodle/admin/index.php?cache=1 page and browser shows me "Firefox has detected that the server is redirecting the request for this address in a way that will never complete" and  " This problem can sometimes be caused by disabling or refusing to accept cookies." I was following this post and found the suggestion that I should delete the folder cache into the moodledata folder. But no folder had been created in such name. I assume the moodledata is the name of my moodle installation directory so I worked accordingly and found cache directory in it. Deleting this directory giving me "Fatal Error".  So I assume that cache folder is essential for moodle since it has some lib.php.  

Now as I stated the problem clearly can anybody suggest me any solution which will work for me. 

Thanks

Soumyajit

In reply to Soumyajit Mandal

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

The moodledata folder is NOT the moodle installation folder so when you deleted the cache folder, you actually deleted part of the code that runs moodle.  The moodledata folder is a separate folder that you should have created during setup.  It should NOT be in your moodle folder. 

At this point, you need to reinstall moodle, find your moodledata folder, and delete the cache folder within it. Or, if you have the original folder that you installed moodle from, copy the cache folder from it over to your installation.  Check that permissions and ownership are correct on that folder after copying. 

Average of ratings:Useful (1)
In reply to Emma Richardson

Re: Site not accessible after installation "Redirect Loop" (New Installation)

by lechiakanthan r -

Hi Frd:

I am using moodel-29 install locally display same error. please help me then which location delete the catch in moodel-29 help me.....

Thank You