CodeIgniter – No input file specified error – .htaccess – PHP5 – Apache 2

Speed Coder

Image Source: Day 486 / 365 – Late Night High Level Coding Courtesy Of: JasonRogers

What the heck is this blog post all about? I am warning you that this is going to be a very technical driven blog post.

I felt so funny that this blog got more traffic from search engine to IT related blog posts than to my Internet Entrepreneur Diary or Weekend Confession blog posts. This blog was started with many IT relate topic to records the problems I ran into and the solutions I found. It’s a good time to give it a little update.

Let’s cut to the chase. I am working a new projects that is running on PHP5, Apache 2 and MySQL. I need to get this project done fast and good. So I finally found one of the best choice from so many PHP frameworks. CodeIgniter seems to be the best one fit my needs. It’s very simple and fast. Although it does not support PHP5 OO programming, but it does run on PHP5.

ci_logo2

I just ran into problem on my shared hosting server, which is running PHP5 as CGI mode on Apache 2.2 according to PHPINFO(). It throws an error when I access page. “No Input File Specified!” Now the problem is solved!

I have no problem to run the application on my local XP based laptop,which runs PHP5 as Apache Module. Obviously, it’s an Apache error. After reaching on Internet and found the solution. If PHP5 is running on Apache 2.2 as CGI mode, which many web hosting company set as default; Apache is not going to support “PATH_INFO” inside Codeigniter. In order to solve the problem, the solutions is very simple!

There are two solutions. No matter which one you choose, you will always have the same step 1.
Step 1: Obviously, PHP running under CGI mode has cgi.fix_pathinfo default to 1. Simply open /system/application/config/config.php file and make sure the following two options are set.

$config['index_page'] = “”;
$config['uri_protocol'] = “AUTO“;

Solutions 1:
Step 2: Create a customized PHP.INI file under the root directory of your site with the following line.

cgi.fix_pathinfo = 0;

Solutions 2:
Step 2: Go to .htaccess file and add question mark after index.php and before slash.

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]

Personally, I choose the Solution 1 with PHP.INI. It seems to run faster. Problem solved!

Related Posts Plugin for WordPress, Blogger...

Share your thoughts with me!

Comments

  1. Jessie Rawlins says

    I’ve just downloaded CodeIgniter 2.1.0 and was having exactly this issue. This solution worked perfectly. Thank you so much.

  2. says

    Had some trouble because of this. Used the second method, and it worked! Thanks.. Although would be great if you could tell me what’s the advantage of using Step – I over II..

    Thanks! Regards, Gokul..

  3. says

    Thanks a lot.
    I have not implemented the first one but the second solution was more easier to implement.
    Just copied and paste the code snippets and the site is up now.

    Thanks a lot again.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge
Loading Facebook Comments Widget ...