【问题标题】:CodeIgniter MY_Controller not working in web serverCodeIgniter MY_Controller 在 Web 服务器中不起作用
【发布时间】:2014-03-28 09:46:09
【问题描述】:

我扩展了 CI_Controller 并制作了我自己的控制器进行扩展。 现在在 localhost (xampp) 中一切正常,但是当我将文件复制到我的 Web 服务器时,我得到了 500 internal server error,这是非常没用的。对我来说奇怪的是,我得到的是内部服务器错误而不是 codeigniter 生成的错误。

到目前为止我尝试过的事情:

1) 尝试使用库文件夹而不是 MY_Controller 的核心

2) 我遇到了服务器只接受小写文件名的问题,所以我尝试了 my_controller 并更改了配置文件 prefix、main.php 扩展名等。 无论如何,这两种尝试似乎都是无用的,因为我没有收到错误说找不到或类似的东西。

当我将 main.php 控制器更改为扩展 CI_Controller 时,一切正常。

我知道我没有提供太多信息,但我不知道该提供什么。同样,它可以在 localhost 中运行。

感谢您提供的任何意见。

【问题讨论】:

  • 你能告诉用户更多关于你的网络服务器的环境吗?
  • 你使用 url_rewriting 吗?
  • 如何更新网络服务器?你是在使用 git 还是类似的东西,所以你可以通过git status 来查看哪些文件被更改了?如果只是 FTP/scp,请确保您已上传所有相关文件。我特别想到了 config/config.php 文件,因为它在这里有相关的配置行:$config['subclass_prefix']

标签: php codeigniter controller


【解决方案1】:

尝试将您的 config.php 更改为。

$config['index_page'] = '';

以及网站的 .htacces 到:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]

【讨论】:

    猜你喜欢
    • 2015-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多