Codeigniter-未指定输入文件

我是 Codeigniter 的初学者,我看了一个 CI 教程,只是想做一件简单的事情。我下载了 CI 并将这个文件添加到控制器目录,但它不能工作。

<?php


class site extends CI_Controller
{
public function index()
{
echo "Hello World";
}


function dosomething()
{
echo "Do Something";
}
}
?>

当我尝试使用 http://..../index.php/site访问它时,我会得到输出... “没有指定的输入文件”... 。顺便说一下,我把这个文件命名为 site.php

124186 次浏览

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

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 !

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

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

to

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

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!

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>

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.