php Codeigniter - 未指定输入文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6118740/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Codeigniter - no input file specified
提问by koool
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.
我是 Codeigniter 的初学者,我看到了一个 CI 教程,只是想做一件简单的事情。我下载了 CI 并将此文件添加到控制器目录,但它不起作用。
<?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/siteI get the output ... "no input file specified" .... by the way, I named the file site.php
当我尝试使用http://..../index.php/site访问它时,我得到了输出......“没有指定输入文件”......顺便说一下,我将文件命名为 site.php
采纳答案by koool
I found the answer to this question here..... The problem was hosting server... I thank all who tried .... Hope this will help others
我在这里找到了这个问题的答案......问题是托管服务器......我感谢所有尝试过的人......希望这会帮助其他人
回答by Ali Mohamed
Just add the ?sign after index.php in the .htaccess file :
只需添加? 在 .htaccess 文件中的 index.php 后签名:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/ [L]
and it would work !
它会起作用!
回答by Sekar Suresh S
Godaddy hosting it seems fixed on .htaccess
, myself it is working
Godaddy 托管它似乎固定.htaccess
,我自己它正在工作
RewriteRule ^(.*)$ index.php/ [L]
to
到
RewriteRule ^(.*)$ index.php?/ [QSA,L]
回答by Randika Vishman
RewriteEngine, DirectoryIndex in .htaccess file of CodeIgniter apps
重写引擎,CodeIgniter 应用程序的 .htaccess 文件中的 DirectoryIndex
I just changed the .htaccessfile contents and as shown in the following linksanswer. And tried refreshing the page (which didn't work, and couldn't find the request to my controller) it worked.
我刚刚更改了.htaccess文件内容,如下面的链接答案所示。并尝试刷新页面(它不起作用,并且找不到对我的控制器的请求)它起作用了。
Then just because of my doubt I undone the changes I did to my .htaccessinside my public_htmlfolder back to original .htaccesscontent. So it's now as follows (which is originally it was):
然后,只是因为我的疑问,我撤消我做我的变化的.htaccess里面我的public_html文件夹回原来的.htaccess的内容。所以它现在如下(原来是这样):
DirectoryIndex index.php
RewriteEngine on
RewriteCond !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/ [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:
并且在index.php
我设置了系统和应用程序的以下路径:
$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!
谢谢!
回答by Winter MC
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:
我的网站托管在 MochaHost 上,我很难设置 .htaccess 文件,以便我可以从我的网址中删除 index.php。然而,经过一些谷歌搜索后,我结合了这个线程和其他答案的答案。我的最终工作 .htaccess 文件具有以下内容:
<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 ^(application|system|private|logs)
# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/ [PT,L]
# Allow these directories and files to be displayed directly:
RewriteCond ^(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?/ [PT,L]
</IfModule>