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.
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!


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!!!
@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!
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!
@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.
@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!
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?
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]
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???
@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.
@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.
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
@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!
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
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
@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!
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.
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!
hi, thanks for your nice info. it safe my site after the hosting company update php and apache.
regards
Just had this pop up on a client’s application, the host must have changed some configuration. Just needed to add the question mark in my RewriteRule and bam, it was back.
this is my .htaccess file in godaddy basically what i am doing is my project is on the subdirectory like
http://www.mydomain.com/lap/codeigniterproject
what .htaccess setting should i use
Options -MultiViews
#Enable mod rewrite
RewriteEngine On
#the location of the root of your site
#if writing for subdirectories, you would enter /subdirectory
RewriteBase /
#Removes access to CodeIgniter system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#’system’ can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn’t true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css
#folders, and the robots.txt file
#Submitted by Michael Radlmaier (mradlmaier)
# I added this line based on some info from other posts
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.+)$ index.php?/$1 [L]
Thanks!
Solution 2 worked fine for me!
You saved my life! ;D
i use .htaccess solution
it works thanks
You greatly helped me. Thank you very much!
But only solution #2 works for me
Great article this questions “?” after .php fix this shit error
Thank You!
Muito Obrigado ; ) THX, me salvou em um projeto
Hello, thanks for this post. You save my live
this worked for me no htaccess just rename php.ini to php5.ini in root directory
http://jawad.pk/blog/2009/03/17/problem-running-codeigniter-over-godaddy/comment-page-1/#comment-11795
@Geomorillo:
Thank you for stopping by. Never had issues with GoDaddy hosting and codeigniter, but it’s good to know there are options out there. Thanks!
Thanks you! Solution 2 works perfectly!
Terence,
I didn’t know you were a CI coder? That’s what my web app is being coded in!
@James:
Welcome to my blog. Yes. I have been a CodeIgniter developer since 2008. It’s very easy to pick up! The only downside is the lack of PHP5 support. Sooner and later, I will move on to YII framework. You have a great site! I thought it was developed on Ruby.
It worked for me:
Options +FollowSymLinks
RewriteEngine on
# Send request via index.php (again, not if its a real file or folder)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^(.*)$ index.php?/$1 [L]
In config.php: $config['uri_protocol'] = ‘QUERY_STRING’;
AWESOME!!!!! Thanks for the solution.
Worked beautifully for me, first time. It was the HTACCESS rules that fixed it.
Hi,
I m facing 404 error in codeigniter 2.2. it is working fine with localhost but while deploying on HOST it is giving 404 ERROR.
URL http://mysoftarticles.com/zaved/demo/justRequestPlease.
http://mysoftarticles.com/zaved/demo/justRequestPlease/phpinfo.php
.htaccess is look like this -
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
++++++++++++++++++++++++++++++++++++++++++++++++++
Kindly help me .
@Zaved:
I can see your site and 404 on the phpinfo.php file. Can’t really tell you want is wrong unless I can see your codeigniter structure. Good luck with your project.
Thanks very much for this
I have an old CI site running a now out of date version, I just noticed this error and wondered what on earth was going on.
I guess my host must have changed PHP versions or soemthing, anyway, quick insert of the ? to .htaccess resolved this within a minute of finding your blog post. I could have spent hours looking for the sollution to that!
Still not sure what changed on my host to break this though, it has been running fine for a couple of years.
Interestingly other sites I have on the same host using Code Igniter seem to be working fine, though their .htaccess is not quite the same. Some small nuance I am oblivious to no doubt!
Surprising how an old post like this can still help people isnt it!
Thanks again
Jez recently posted..GSA Website Submitter Review
@Jez:
Glad that I can help. I am still using old version of CodeIgniter. Will move on to the new one when they are more mature.
You really made my day. I was sooooooooo happy when I run into this post! Billion thank you!
Thanks! Great post! helped a lot.
Glad that I can help!
I wonder how many of you are moving on the CodeIgniter 2?
Thank you for sharing, what a time saver advice, thanks!
Thank you. This saved me!
Your solution worked with one minor change. I had to set: $config['uri_protocol'] = ‘QUERY_STRING’;
Other than that minor thing, this solution worked on the production server configuration. This experience also tells me not to let clients pick their host!
Anyway, again, thank you. Very well written post with good info.
Frank Villasenor recently posted..Unit Testing Django
@Frank:
Thank you for stopping by and glad that it helps you get your problem solved. I was not aware the query_string will matter. I guess it’s based on how your web hosting config your PHP.ini.
Thanks for the info too!
Thank you so much!
I came upon your article searching for a solution for the same “No Input File Specified!” issue that alegro cart is throwing out. No one in their forum/support on this…
You enlightened my day!
RewriteRule ^(.*) index.php?/$1 [L,QSA]
instead of
RewriteRule ^(.*) index.php/$1 [L,QSA]
works. Thank you again!
Luca recently posted..Azi, ce mancam?
@Luca:
Glad that it solved your problem! Thank you for stopping by!
Thanks man. Saved my time.
Nice! .htaccess also worked for me
) Thanks Terence!
Awesome!!!
it worked!! solution 1!
Well. Thanks to everyone who comment on this post. I am glad that many of you have solve the problem.
I wonder if anyone moved on to the newer version of CodeIgniter?
Terence Chang recently posted..Lomaki Pueblo And Lomaki Pueblo In Wupatki National Monument