500 Internal Server Error in CodeIgniter application

13,480

I have checked your other applications and found that most of them are working except for the 'hrs'. You should adopt the step by step approach.

  1. First, rename the index.php that comes with codeigniter and create your own index.php or index.html and try acccessing the same. See if it works or not
  2. If still not working, then delete the .htaccess file and try accessing those newly created index files and check
  3. If your are able to access the index files with the .htaccess file then there should be some issue with CodeIgniter. For which you should start enabling the DEBUG mode
  4. If you find that issue with CodeIgniter, then once again restore the index.php of the CodeIgniter and modify your config.php for $config['log_threshold'] = 4. Then in the index.php add the below code

    error_reporting(E_ALL); 
    ini_set('display_errors', 1);
    

    Then try the application.

Hope by this, you should be able to get the error details. Let us know the information so that we can help you further.

Share:
13,480

Related videos on Youtube

Sizzling Code
Author by

Sizzling Code

I am passionate about what I do and always give 100%. Whan I undertake a project or task, I don't just complete it, I go the extra mile and make it better than requested.

Updated on June 04, 2022

Comments

  • Sizzling Code
    Sizzling Code almost 2 years

    I did some work locally on CodeIgniter web application. It works fine locally but when uploaded to live server.

    I get blank page and when checked through the Firebug, I got internal server error message in console of Firebug.

    I am searching for solution from 2 days and there are a lot of answers to internal server error like .htaccess might be misconfigured or mod_rewrite might not be enabled etc.

    Here what I have tested so far.

    1. mod_rewrite is working fine on cpanel linux shared hosting server. Also tested it to make sure by creating a simple .htaccess file and test2.php file.

    enter image description here

    2. .htaccess seems fine to me, I have tried many other approaches but no use, however this .htaccess works for me on wampp and xampp servers locally.

        DirectoryIndex index.php <IfModule mod_rewrite.c>
    
        Options +FollowSymLinks -Indexes    RewriteEngine on
    
        #RewriteBase /projects/HouseRentSystem  RewriteBase /demos/hrs
         # Hide the application and system directories by redirecting the request to index.php
         RewriteRule ^(application|system|\.svn) index.php?/$1 [L]
         RewriteCond %{REQUEST_FILENAME} !-f
         RewriteCond %{REQUEST_FILENAME} !-d
         RewriteRule ^(.*)$ index.php?/$1 [L] </IfModule>
    
     <IfModule !mod_rewrite.c>
         ErrorDocument 404 index.php </IfModule>
    

    But to make sure, I have also tried to remove the .htaccess and directly accessed the controller by using the index.php in url. but no success there so its not .htaccess issue as even with index.php I get the internal server error.

    3. Tested if base URL or database settings might not be ok. But they are OK.

    I am confused what to check more? Why I can't make this application to work on my shared hosting?

    Here is the application link getting error. It's a blank page. Error shows in console.

    enter image description here

    Checked the Error log in cPanel to see if any error there, but it's empty.

    enter image description here

    Update:

    Thanks to @vinod Tigadi

    Finally found out some issues.

    Error log of cpanel is empty, but needed to check the error log in root folder of my application/project.

    Plus I had prefix defined in config was

    $config['subclass_prefix'] = 'MY_';
    

    whereas my main controller file name was My_Controller, y was small. I could not know of this change because of blank page and no errors and didn't knew of error log file location.

    • Mike
      Mike almost 9 years
      Don't try to guess what the error is. Check the error log. It should tell you what's going on.
    • Sizzling Code
      Sizzling Code almost 9 years
      i checked the error log in cpanel, its empty :(
    • Rejoanul Alam
      Rejoanul Alam almost 9 years
      Is csrf_protection enabled?
    • Sizzling Code
      Sizzling Code almost 9 years
      @RejoanulAlam No its set to FALSE in my config file..
    • Mike
      Mike almost 9 years
      If you're getting a 500 error it should to be going to some error log file somewhere. I'm guessing you're just looking at the wrong one. I haven't used cpanel for years, but I seem to recall it adding a file called error_log to the directory within your web root when a php error occurs. Check for that. If not, see stackoverflow.com/questions/8955411/…. If you still can't get it, contact your host to have them point you in the right direction.
    • Rejoanul Alam
      Rejoanul Alam almost 9 years
      can you show your ajax code?
    • Sizzling Code
      Sizzling Code almost 9 years
      @RejoanulAlam What ajax code?? i have used ajax in many places?? but what specifically ajax code should i show??
    • Rejoanul Alam
      Rejoanul Alam almost 9 years
      Only those code (ajax request) are running on page ready in webteezy.com/demos/hrs
    • Sizzling Code
      Sizzling Code almost 9 years
      @RejoanulAlam Sir, There is no ajax used in first page. I have this application on github. currently i am working on it so its not complete. github.com/pakistanihaider/HouseRentSystem/blob/master/theme‌​s/… All my code is on the github..
  • Sizzling Code
    Sizzling Code almost 9 years
    i already did tried it to make sure of my .htaccess is working. i put echo in my index.php file and it echoed perfectly.. so issue is with codeigniter.. but i am not sure how to find where actually the issue lies. i did error_reporting to E_ALL but still no use. i get internal server error in console. i checked database paths. but everthing seems fine as it works on local wamp/xampp but not on online shared hosting server?
  • Vinod Tigadi
    Vinod Tigadi almost 9 years
    Did you enable the ERROR_REPORTING and tried? Not just Error Reporting, but even the 'ini_set(display_errors). If not, give it a try and let us know. Also the Config - log_threshold to 4
  • Sizzling Code
    Sizzling Code almost 9 years
    i just changed log_threshold from 0 to 4 but still getting that same Internal server error in console.
  • Sizzling Code
    Sizzling Code almost 9 years
    great sir, Loader Class Initialized is showing in the log of local but not on the live server and follow on nothing loads.. looks like something is wrong with the Loader Class.. but what is loader class??
  • Vinod Tigadi
    Vinod Tigadi almost 9 years
    Great!! Something you started seeing. Which version of CI are you using? Loader Class is used to load all the different elements of the CI - Refer ellislab.com/codeigniter/user-guide/libraries/loader.html
  • Vinod Tigadi
    Vinod Tigadi almost 9 years
    Ya it's pretty old. But there are people who uses CI 1.7.x too!!. Yes, there seems to be some server issue about some of the libraries that you are using. Now you may have to use the kind of developer's debugging techniques to find the root case. Because further to this, I may not be of much help in remote debugging ;-). All the best..
  • Vinod Tigadi
    Vinod Tigadi almost 9 years