Moodle 3.1 too many redirects

Moodle 3.1 too many redirects

by Bernardo Estêvão -
Number of replies: 2

Hi,

I'm kinda new to setting up  a moodle server, so sorry for any mistakes or dumb statements I might write.

I've installed Moodle 3.1 in a new server according to this guide. Everything went smooth, I was able to access moodle from the server (localhost).

The problem appeared when trying to change it to one of the company's public domain.

So, from what I understood in said guide, went to "config.php" and changed "$CFG->wwwroot" to "http//moodle.companyname.com" (example, of course), and also changed to "DocumentRoot /var/www/html/moodle" in the apache2 "000-default.conf", so I could access moodle just by typing "http//moodle.companyname.com" in the browser.

At this point I got the "too many redirects" problem. I've been searching for days but still no solution. Tried to delete "moodledata" folder as sugested in other topics, tried to change back apache's DocumentRoot to "/var/www/html", but then I would only access the apache default "welcome" page.

Any ideas what I might be doing wrong?

Thanks

Average of ratings: -
In reply to Bernardo Estêvão

Re: Moodle 3.1 too many redirects

by Bernardo Estêvão -

For thoose who might still have this problem, I'll write here how I managed it.

It seems that ultimatly, this was a PHP/Apache problem, not moodle.

The problem was that somehwere in Moodle php files it uses the "HTTP_HOST", wich was returning an incorrect address. Beeing new to Apache, I researched to find how to fix this. Read about ".htaccess" file and "virtualhosts", but none solved it.

Using "phpinfo()" I found that the "SERVER_NAME" was returning the correct value, so I replaced inside my installation of moodle all the "HTTP_HOST" entries for "SERVER_NAME", uing the command: 

"sudo find /var/www/html/moodle/ -type f -readable -writable -exec sed -i "s/HTTP_HOST/SERVER_NAME/g" {} \;


I dont recomend trying this solution unless you're sure you have the same problem!

In reply to Bernardo Estêvão

Re: Moodle 3.1 too many redirects

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I don't recommend it at all. Sounds like an Apache issue rather than Moodle. I would have fixed the issue at source.