moodle fastcgi internet explorer error 500 RRS feed

  • Question

  • User387614326 posted

    I have the same issue, I only copy the text reference:



    In testing the FastCGI for IIS component with PHP and moving away from ISAPI PHP implementation we have managed to develop a small problem with moodle login form, and I was wondering if anyone might have any idea what is causing this, or has encountered it in the past.

    We are currently using front end moodle server with Windows 2003 Server/IIS6 and PHP 5.2.3. Our moodle back end server is Windows 2003 with MySQL 5.0.45 running on. PHP has been implemented in ISAPI mode, and everything running ok, but not very quickly (As an experiment we have changed over from ISAPI PHP to FastCGI for IIS. The speed increase is very noticeable, and moodle works fine, apart from a login issue.

    When a user puts in an incorrect password on the moodle login screen IE6 gives a HTTP 500 internal server error message and Firefox 2 reports the following single text line (IP and hostname removed) for any user,

    [client xxx.xxx.xxx.xxx] http://moodle Failed Login: admin Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv: Gecko/20070725 Firefox/


    Instead of reporting back to the moodle login page with “invalid password” appearing like normal (as happens when running in ISAPI mode)

    What seems to be happening is the PHP error is not being sent back to the login.php to display correctly, and just appearing in the browser, but unfortunately I don’t have any idea why this would happen,

    Is anyone able to help and shed some light on this for me please?


    I test changing the 500 error with personalizated page, using a redirect javascript to the login.php but dont work. 


    Saturday, January 12, 2008 8:11 AM

All replies

  • User387614326 posted

    Any one have ideas about this?


    I can send $$$ for this solution (via paypal, western union) Is urgent for me!!



    Friday, January 18, 2008 10:20 AM
  • User-625067700 posted


    Comment out line 4766 (at least is that line in moodle 1.7.4)

     For some stupid reason moodle sends a 303 response before a location redirect, comment that line out and everything will work fine.

    Wednesday, January 23, 2008 4:27 PM
  • User387614326 posted

     hello friend, thanks for your reply.

    I have moodle 1.8 and comment the line 5310 

      $delay = 0;
            //try header redirection first
            //@header($_SERVER['SERVER_PROTOCOL'] . ' 303 See Other');
            //302 might not work for POST requests, 303 is ignored by obsolete clients
            @header('Location: '.$url);
            //another way for older browsers and already sent headers (eg trailing whitespace in config.php)
            echo '<meta http-equiv="refresh" content="'. $delay .'; url='. $encodedurl .'" />';
            echo '<script type="text/javascript">'. "\n" .'//<![CDATA['. "\n". "location.replace('$surl');". "\n". '//]]>'. "\n". '</script>';   // To cope with Mozilla bug


    this dont work :(   I dont know if downgrade to 1.7.4. Microsoft guys dont have solution to this using FastCGI. 

    Saturday, January 26, 2008 5:13 PM
  • User387614326 posted

    this is the code


    function redirect($url, $message='', $delay=-1, $adminroot = '') {
    4994 global $CFG;
    4996 if (!empty($CFG->usesid) && !isset($_COOKIE[session_name()])) {
    4997 $url = sid_process_url($url);
    4998 }
    5000 $message = clean_text($message);
    5002 $url = html_entity_decode($url);
    5003 $url = str_replace(array("\n", "\r"), '', $url); // some more cleaning
    5004 $encodedurl = htmlentities($url);
    5005 $tmpstr = clean_text('<a href="'.$encodedurl.'" />'); //clean encoded URL
    5006 $encodedurl = substr($tmpstr, 9, strlen($tmpstr)-13);
    5007 $url = html_entity_decode($encodedurl);
    5008 $surl = addslashes($url);
    5010 /// when no message and header printed yet, try to redirect
    5011 if (empty($message) and !defined('HEADER_PRINTED')) {
    5013 // Technically, HTTP/1.1 requires Location: header to contain
    5014 // the absolute path. (In practice browsers accept relative
    5015 // paths - but still, might as well do it properly.)
    5016 // This code turns relative into absolute.
    5017 if (!preg_match('|^[a-z]+:|', $url)) {
    5018 // Get host name http://www.wherever.com
    5019 $hostpart = preg_replace('|^(.*?[^:/])/.*$|', '$1', $CFG->wwwroot);
    5020 if (preg_match('|^/|', $url)) {
    5021 // URLs beginning with / are relative to web server root so we just add them in
    5022 $url = $hostpart.$url;
    5023 } else {
    5024 // URLs not beginning with / are relative to path of current script, so add that on.
    5025 $url = $hostpart.preg_replace('|\?.*$|','',me()).'/../'.$url;
    5026 }
    5027 // Replace all ..s
    5028 while (true) {
    5029 $newurl = preg_replace('|/(?!\.\.)[^/]*/\.\./|', '/', $url);
    5030 if ($newurl == $url) {
    5031 break;
    5032 }
    5033 $url = $newurl;
    5034 }
    5035 }
    5037 $delay = 0;
    5038 //try header redirection first
    5039 @header($_SERVER['SERVER_PROTOCOL'] . ' 303 See Other'); //302 might not work for POST requests, 303 is ignored by obsolete clients
    5040 @header('Location: '.$url);
    5041 //another way for older browsers and already sent headers (eg trailing whitespace in config.php)
    5042 echo '<meta http-equiv="refresh" content="'. $delay .'; url='. $encodedurl .'" />';
    5043 echo '<script type="text/javascript">'. "\n" .'//<![CDATA['. "\n". "location.replace('$surl');". "\n". '//]]>'. "\n". '</script>'; // To cope with Mozilla bug
    5044 die;
    5045 }
    the problem is exactly related by PolyPill guy, moodle sends a 303 response before a location redirect but I am unable to handle this.


    Saturday, January 26, 2008 8:48 PM
  • User-625067700 posted

    I took a look at moodle 1.8 since we'll eventually have to upgrade to it.

    Basically any header() that outputs anything the fastcgi handler doesn't understand causes it to crash, it should really just ignore things instead, but on the weblib.php comment out line 4944. "@header('HTTP/1.0 404 Not Found');"

     There might be more lines like that, I'll look more and see what I come up with.

    Sunday, January 27, 2008 2:37 PM
  • User-625067700 posted
    I could only find 2 more calls to header in moodle 1.8 that cause fastcgi to crash and they're in the same file. Let me know if commenting out all these lines helps.


    lib/filelib.php    line 656    @header('HTTP/1.1 206 Partial content'); 

    lib/filelib.php    line 678    @header('HTTP/1.1 206 Partial content');

    Sunday, January 27, 2008 2:48 PM
  • User-1095078941 posted

    Have you checked the possibility that maybe you are installing in the wrong directory path? I faced this same issue on a LAMP based Moodle hosting (https://www.cloudways.com/en/moodle-hosting.php ). They told me i am supposed to install Moodle in public_html directory.

    Tuesday, August 25, 2020 6:59 PM