php Codeigniter 没有输入文件指定错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10361742/
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 error
提问by bukowski
I have installed CI in subdirecotry www.siteb.com/rexona
我已经在子目录 www.siteb.com/rexona 中安装了 CI
My .htaccess inside www.siteb.com/rexona :
我在 www.siteb.com/rexona 中的 .htaccess :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /rexona
#Removes access to the 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/ [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)
RewriteCond !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/ [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
In config.php:
在 config.php 中:
$config['index_page'] = '';
$config['base_url'] = '';
$config['uri_protocol'] = 'AUTO';
Whenever I try access controllers I get No input file specified. However it does load default controller, but I cant access any methods in default controller either.
每当我尝试访问控制器时,我都会得到No input file specified。但是它确实加载了默认控制器,但我也无法访问默认控制器中的任何方法。
Any thoughts? Thanks.
有什么想法吗?谢谢。
回答by Repox
Your uri_protocolneeds to be set to something - at least set it to auto.
您uri_protocol需要设置为某些东西 - 至少将其设置为自动。
The error you are getting is because PHP runs as CGI which means you need to pass the URL rewrite to index.php?/$1instead (note the question mark).
您得到的错误是因为 PHP 作为 CGI 运行,这意味着您需要将 URL 重写传递给index.php?/$1(注意问号)。
回答by Sekar Suresh S
Godaddy hosting, it seems fixed on.htaccess, myself it is working by changing:
Godaddy 托管,它似乎是固定的on.htaccess,我自己正在通过更改:
RewriteRule ^(.*)$ index.php/ [L]
to
到
RewriteRule ^(.*)$ index.php?/ [QSA,L]
回答by Wesley Murch
Your $config['uri_protocol']should not be empty. The default is AUTO, passing in an empty string will break the core URI class, which is used to route your requests through the Router class.
你$config['uri_protocol']不应该是空的。默认为AUTO,传入空字符串将破坏核心 URI 类,该类用于通过 Router 类路由您的请求。
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string. The default setting of 'AUTO' works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'AUTO' Default - auto detects
| 'PATH_INFO' Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI' Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol'] = 'AUTO';
As the comments say: "If your links do not seem to work, try one of the other delicious flavors".
Empty string is not one of those flavors, it would end up trying to read from $_SERVER[''], which is normally going to be empty.
正如评论所说:“如果您的链接似乎不起作用,请尝试其他美味之一”。
空字符串不是这些风格之一,它最终会尝试从 读取$_SERVER[''],通常是空的。
回答by Angelo Lopez
I get the same error in hostinger free account, resolve with the issue presented by jhon foo above.
我在托管服务商免费帐户中遇到了同样的错误,解决了上面 jhon foo 提出的问题。
my .htaccess
我的.htaccess
RewriteBase /MY_SUBFOLDER_UNDER_HTML_DIRECTORY/
RewriteEngine on
RewriteBase /mY_subfolder/
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/##代码## [QSA,L]
This work fine, thanks a lot!
这项工作很好,非常感谢!

