我正试图访问一个控制器方法设置来进行简单的数据库插入,但我无法访问它。我可以从web访问它,而且我不需要登录即可运行它。
但是 如果我导航到我的项目目录,并且从我的命令行类型:
php index.php My_Controller/My_Method
相反,它运行welcomecontrollerfunction __construct()
并喷出一堆未定义的索引错误。事实上,我可以键入php index.php jibberish/doesnotexist
,它仍然会给我
<p>Severity: Notice</p>
<p>Message: Undefined index: HTTP_HOST</p>
<p>Filename: controllers/welcome.php</p>
<p>Line Number: 45</p>
为什么它运行欢迎控制器而不是我指定要运行的控制器?我还修改了.htaccess文件以删除index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
如果我尝试在没有基本目录中的index.php的情况下进行操作,我会得到"无法打开输入文件"。
已解决:确保您的uri_procol设置为auto:
$config['uri_protocol'] = 'AUTO';