CodeIgniter - No input file specified error - .htaccess - PHP5 - Apache 2
Tips & Tricks, PHP, Technology August 28th, 2008Image 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.
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!
Popularity: 38% [?]
Save To Del.icio.us | Digg This | Stumble It
20 Responses to “CodeIgniter - No input file specified error - .htaccess - PHP5 - Apache 2”
Leave a Comment
Comment PolicyA comment will be DELETED/MODIFIED if:
- Contains links to splogs or MFA (Made For Adsense) sites
- Contains links to a non-blog related sites
- Contains racists, drugs or illegal statements and stuff like that
- Adds no value to the discussion












August 28th, 2008 at 10:00 pm
[…] Just has an error related to PHP5 running on Apache. Problem is solved and are ready at CodeIgniter - No input file specified error - .htaccess - PHP5 - Apache 2. […]
August 29th, 2008 at 1:20 am
Well i did both step1 and step2 alternatively. It still returns me “404 Page Not Found The page you requested was not found.” error. Please help!!!
August 29th, 2008 at 8:35 am
@Yamin:
404 page not found is a different story. I checked your site, it shows “No input file specified” error. Looks like you are missing something. I have also tried index.php?/social-media/ or index.php/social-media/ without good luck on your site. So here are few questions I want to ask you to help get this solved.
1. What version of PHP are you running? PHP4 or PHP5?
2. Is PHP running as CGI mode or Apache Module?
If you are running PHP as Apache Module, it should be no brainer. Good luck!
August 29th, 2008 at 8:52 am
This has completely taken me by surprise. I do not know what is going on, but whatever it is, I hope that you will get back to your normal blogging on this site!
August 29th, 2008 at 9:01 am
@Yamin:
I just give it a try with the following link on your site.
social-media/index.php?/test/
It throw an 404 page not found error. It’s the default CodeIgniter page not found error. I thought you were saying the default Apache 404 page not found error.
So I tried social-media/index.php
It throws “An Error Was Encountered - Unable to load the requested class: myclass”.
Looks like you have changed something in the config file or class name, which cause the problem. Keep me post.
August 29th, 2008 at 9:04 am
@Rummuser:
Thank you for coming back! I have to admit that I was not very active on my blog recently. Working on my new project to achieve the life time.
Stay tune!
August 30th, 2008 at 4:47 am
Hi Chang,
My Php Version: 5.2.6 and Server API: CGI/FastCGI. And i also found out that Virtual Directory Support is set to disabled in my php.ini. I dont know whether its causing the problem. But surprisingly i got another project which is working fine with mod_rewrite in the same server although the virtual directory support is disabled. But i’ve php5, server api: Apache 2.2 Handler, and virtual directory enabled in my local pc. Does that help?
August 30th, 2008 at 4:50 am
By the way, my apache .htaccess has this following codes:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|ext|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
August 30th, 2008 at 8:09 am
Hi chang,
I got it worked out without the SEO friendly URL (i.e without rewrite rule). Since the app i’m working doesn’t require SEO friendly url, i kind of accepted the sacrifice that i had to make. But i found something peculiar in codeigniter. Whenever i try to destroy the session with the following code:
$this->CI->session->set_userdata(’sessionvar’, false);
$this->CI->session->sess_destroy();
It destroys the session in FF. But not in IE. However i have installed the session patch that they (codeigniter) have provided, so its working in FF but not in IE. Have any suggestion for me pls???
September 2nd, 2008 at 11:58 am
@Yamin:
I hope you found your solutions. Your .htaccess file looks good to me. Just wondering if you every try to add question mark after index.php. Hope that solved your problem. Many hosting site turn off virtual directory so you can’t add your own.
September 2nd, 2008 at 12:01 pm
@Yamin:
I always try to set session data to NULL or empty string before destroy them. I have not has problem with IE7. Can’t really duplicate with it.
September 8th, 2008 at 12:18 pm
[…] While working on my web project, I changed the way I used to code. I no longer start everything from scratch. I start using open source PHP framework. It actually speeds up my coding. The downside is that I have to learn the framework. So far, the best PHP framework that fit my need is CodeIgniter. Although it’s primary for PHP4, it still runs on PHP4 with a little tweek. […]
September 24th, 2008 at 2:36 am
THANKS A LOT!!
I recently was moved servers inside Dreamhost and this was killing me without apparent reason. It was working one day, the day after, it wasn’t.
I’m glad I found your post : )
Cheers!
Juan
September 24th, 2008 at 11:06 am
@Zarate:
I am glad that you got your problem solved! I checked out your site. It’s very interesting. I just learned from you site that there are new languages to create a better user experience. I like your site a lot. I guess that you speak multiple languages.
I will keep you on my talented developer list.
Thank you for stopping by!
October 14th, 2008 at 10:58 am
Your problem is solved and that is very great,, i also found that your website is truly interested and I start using open source PHP framework.
ust has an error related to PHP5 running on Apache
October 14th, 2008 at 2:49 pm
Dear Terence,
your solution just saved my ass.
I used the second, the first wouldn’t work for me.
Honestly, after recompiling php/apache it just started doing this weird behaviour.
Cheers
October 15th, 2008 at 2:25 pm
@swap market:
I hope that I found codeigniter much earlier. I just found it few months ago and love how simple it is to implement complex applications. PHP5 + MySQL 5 + Apache2 + CodeIgniter is a great combination.
@Sean:
I am glad that you got your issues resolved. It took me a while to figure out.
Thank you for stopping by!
November 10th, 2008 at 2:07 pm
Thank you so much! Option #2 worked for me. I searched and found many examples of fixes but none worked until I tried your. I really appreciate it.
November 13th, 2008 at 4:42 am
Hi!
Thank you for your solution!
My hosting provider won’t provide IMAp module for PHP by default and after recompiling PHP for me with this module all my site (except index page) stopped working showing “No input file specified”.
I used solution 2 and it worked for me!
Thanks!
December 17th, 2008 at 7:10 am
hi, thanks for your nice info. it safe my site after the hosting company update php and apache.
regards