Codeigniter - no input file specified

CodeigniterPhp

Codeigniter Problem Overview


I am a beginner in Codeigniter and I saw a CI tutorial and was just trying to do a simple thing. I downloaded the CI and added this file to controller directory, but it won't work.

<?php

class site extends CI_Controller
{
	public function index()
    {
		echo "Hello World";
	}
		
	function dosomething()
	{
		echo "Do Something";
	} 	
}    
?>

When I try to access it using http://..../index.php/site I get the output ... "no input file specified" .... by the way, I named the file site.php

Codeigniter Solutions


Solution 1 - Codeigniter

Just add the ? sign after index.php in the .htaccess file :

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

and it would work !

Solution 2 - Codeigniter

Godaddy hosting it seems fixed on .htaccess, myself it is working

RewriteRule ^(.*)$ index.php/$1 [L]

to

RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

Solution 3 - Codeigniter

I found the answer to this question here..... The problem was hosting server... I thank all who tried .... Hope this will help others

Godaddy Installation Tips

Solution 4 - Codeigniter

RewriteEngine, DirectoryIndex in .htaccess file of CodeIgniter apps

I just changed the .htaccess file contents and as shown in the following links answer. And tried refreshing the page (which didn't work, and couldn't find the request to my controller) it worked.

Then just because of my doubt I undone the changes I did to my .htaccess inside my public_html folder back to original .htaccess content. So it's now as follows (which is originally it was):

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]

And now also it works.

Hint: Seems like before the Rewrite Rules haven't been clearly setup within the Server context.

My file structure is as follows:

/
|- gheapp
|    |- application
|    L- system
|
|- public_html
|    |- .htaccess
|    L- index.php

And in the index.php I have set up the following paths to the system and the application:

$system_path = '../gheapp/system';
$application_folder = '../gheapp/application';

Note: by doing so, our application source code becomes hidden to the public at first.

Please, if you guys find anything wrong with my answer, comment and re-correct me!
Hope beginners would find this answer helpful.

Thanks!

Solution 5 - Codeigniter

My site is hosted on MochaHost, i had a tough time to setup the .htaccess file so that i can remove the index.php from my urls. However, after some googling, i combined the answer on this thread and other answers. My final working .htaccess file has the following contents:

<IfModule mod_rewrite.c>
	# Turn on URL rewriting
	RewriteEngine On

	# If your website begins from a folder e.g localhost/my_project then 
	# you have to change it to: RewriteBase /my_project/
	# If your site begins from the root e.g. example.local/ then
	# let it as it is
	RewriteBase /

	# Protect application and system files from being viewed when the index.php is missing
	RewriteCond $1 ^(application|system|private|logs)

	# Rewrite to index.php/access_denied/URL
	RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]

	# Allow these directories and files to be displayed directly:
	RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|public|app_upload|assets|css|js|images)

	# No rewriting
	RewriteRule ^(.*)$ - [PT,L]

	# Rewrite to index.php/URL
	RewriteRule ^(.*)$ index.php?/$1 [PT,L]
</IfModule>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkooolView Question on Stackoverflow
Solution 1 - CodeigniterAli MohamedView Answer on Stackoverflow
Solution 2 - CodeigniterSuresh SekarView Answer on Stackoverflow
Solution 3 - CodeigniterkooolView Answer on Stackoverflow
Solution 4 - CodeigniterRandika VishmanView Answer on Stackoverflow
Solution 5 - CodeigniterWinter MCView Answer on Stackoverflow