Codeigniter - no input file specified
Asked Answered
F

6

88

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

Fleury answered 25/5, 2011 at 1:56 Comment(2)
Try checking out this link and see if it fixes the problem.Hosmer
No doesnt help thanks for the effortFleury
F
38

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

Fleury answered 25/5, 2011 at 2:33 Comment(1)
change above line according to your application directory like if you application is not on root directory , write following code in place of above line RewriteRule ^(.*)$ /sub-directory/index.php?/$1 [L,QSA]Vachil
M
310

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 !

Matadi answered 25/10, 2012 at 4:33 Comment(8)
For me this serves a 301 redirect and I end up with /?/ in the URL.Hoar
@Ali Mohamed, which of the htaccess file do you add this line? I tried but does not have any effectMaffa
@Maffa you need to place this snippet in .htaccess file in your project directory.Matadi
change above line according to your application directory like if you application is not on root directory , write following code in place of above line RewriteRule ^(.*)$ /sub-directory/index.php?/$1 [L,QSA]Vachil
where is the .htaccess? I can't find itManganate
@Manganate that would be in codeigniter root directory besides index.phpMatadi
@AliMohamed for some reason mine didn't have one, So I had to create a .htaccess in the root directoryManganate
Worked like a Charm.. . In this programming world One "?" can also change the picture.. .Gaudette
S
63

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

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

to

RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
Simplify answered 18/3, 2013 at 13:38 Comment(2)
change above line according to your application directory like if you application is not on root directory , write following code in place of above line RewriteRule ^(.*)$ /sub-directory/index.php?/$1 [L,QSA]Vachil
Its getting me 404 page not found with CI 3Brainsick
F
38

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

Fleury answered 25/5, 2011 at 2:33 Comment(1)
change above line according to your application directory like if you application is not on root directory , write following code in place of above line RewriteRule ^(.*)$ /sub-directory/index.php?/$1 [L,QSA]Vachil
B
18

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!

Barmecide answered 22/11, 2014 at 6:57 Comment(0)
V
1

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>
Villanovan answered 1/10, 2018 at 19:38 Comment(1)
This solved my problem and got my site working as of October 2021. Thanks!Residue
S
0

One of my Codeigniter apps started returning this error after i restarted my server. When I checked the Codeigniter error log it says something like: "...[error] 879#0: *273 FastCGI sent in stderr: "PHP message: PHP Warning: Unknown: open_basedir restriction in effect. File(/pathToWebsiteRootFolder/index.php) is not within the allowed path(s): ". So I added this: open_basedir= /pathToWebsiteRootFolder/index.php:

To a user.ini file I created in my website root folder.

And this Solved it.

FYI: Im using an NGINX web server.

However, Its strange because I didn't have to do this for the other Apps on the same server.

Spectre answered 14/11, 2022 at 12:51 Comment(1)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewMaltzman

© 2022 - 2024 — McMap. All rights reserved.