CodeIgniter 500 内部服务器错误
我下载了一个使用 CodeIgniter 编写的 PHP 脚本。当我从本地主机运行它时,进入管理文件夹时,它再次显示本地主机。此外,当从我的 Web 主机运行时,它显示 500 内部服务器错误。
我从 http://localhost/myproj 运行该网站,它有效。然后,当我尝试转到位于 http://localhost/myproj/administrator 的管理页面时,它会给出 500 内部服务器错误。
我在这里读到这可能是由于 .htaccess 文件中的错误代码造成的。这是我现在的 .htaccess 文件
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
请帮助我。我知道这可能是一个非常小的问题,但我无法找到错误。
I downloaded a PHP script written using CodeIgniter. when I run it from the localhost, on going to the admin folder, it shows localhost again. Also when running from my web host, it shows a 500 Internal Server Error.
I run the site from http://localhost/myproj It works. Then when I try to go to the admin page which is at http://localhost/myproj/administrator, it gives a 500 Internal Server Error.
I read here that this might be due to a wrong code in the .htaccess file. This is my present .htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
Please help me. I know it might be a very small problem, but I'm unable to find the error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
聚会已经很晚了,但是,我认为解决 CodeIgniter 中 500 个内部服务器错误的最佳方法是在 config 文件夹中的 Config.php 文件中启用错误日志功能,并设置一个阈值,即 $config['log_threshold'] = 1,2,3,4,具体取决于您要查看的日志。
Pretty late to the party but, i think the best approach to 500 internal server errors in CodeIgniter would be to enable the error log functionality in the Config.php file in the config folder and set a threshold value i.e. $config['log_threshold'] = 1,2,3,4 depending on the logs you want to view.
这可能与此线程不再相关,但希望对某人有所帮助。
在过去的一个小时里,我遇到了 500 个错误,因为我的(蹩脚)服务器上运行的 php 版本不支持控制器返回的数组。看起来微不足道,但具有代码点火器错误的特征。
我不得不使用:
而不是
干杯
This probably isn't relevant any more to this thread, but hopefully helpful to somebody.
I've had 500 errors for the past hour as I had a controller return an array not supported by the php version ran on my (crappy) server. Seems trivial but had the hallmarks of a codeigniter error.
I had to use:
Instead of
Cheers
这对我来说很好用
This works fine for me
如果您使用本地服务器,当基本模块未启用时,Wampserver 中会遇到此问题。
您可以通过以下方式启用它们:
左键单击 Wampsever 图标
转至 APACHE ->; APACHE MODULES
向下滚动并找到“rewrite_module”和“headers_module”
然后将它们标记为选中
它将自动重新启动。完毕。
If your are using local server, this problem is faced in Wampserver when the essential modules are not enable.
You can Enable them with:
Left click on Wampsever icon
Go to APACHE -> APACHE MODULES
scroll down and find "rewrite_module" and "headers_module"
Then mark them check
It will restart automatically. Done.
500 错误的问题(使用 CodeIgniter),使用不同的 apache 设置,当 PHP 配置出现错误时,它会显示 500 错误。
以下是如何使用 CodeIgniter 触发 500 错误:
请检查您的 apache 错误日志,其中应该有一些有趣的信息。
The problem with 500 errors (with CodeIgniter), with different apache settings, it displays 500 error when there's an error with PHP configuration.
Here's how it can trigger 500 error with CodeIgniter:
Please check your apache error logs, there should be some interesting information in there.
为了防止其他人偶然发现这个问题,我继承了一个旧的 CodeIgniter 项目,并且在安装它时遇到了很多麻烦。
我浪费了大量时间尝试创建该网站的本地安装并尝试了所有方法。最后,解决方案很简单。
问题是较旧的 CodeIgniter 版本(如 1.7 及更低版本)无法与 PHP 5.3 一起使用。解决方案是切换到 PHP 5.2 或更旧的版本。
Just in case somebody else stumbles across this problem, I inherited an older CodeIgniter project and had a lot of trouble getting it to install.
I wasted a ton of time trying to create a local installation of the site and tried everything. In the end, the solution was simple.
The problem is that older CodeIgniter versions (like 1.7 and below), don't work with PHP 5.3. The solution is to switch to PHP 5.2 or something older.
您正在尝试从站点 URL 中删除 index.php,对吗?
尝试将
$config['uri_protocol']
设置为REQUEST_URI
而不是AUTO
。You're trying to remove index.php from your site URL's, correct?
Try setting your
$config['uri_protocol']
toREQUEST_URI
instead ofAUTO
.确保您的根
index.php
文件具有正确的权限,其权限必须是0755
或0644
Make sure your root
index.php
file has the correct permission, its permission must be0755
or0644
对您的 .htaccess 文件尝试以下操作:
Try this to your .htaccess file:
删除httpd.conf(apache配置文件)中的注释:
remove comment in httpd.conf (apache configuration file):
每当我在子目录中运行 CodeIgniter 时,我都会为其设置
RewriteBase
。尝试将其设置为/myproj/
而不是/
。Whenever I run CodeIgniter in a sub directory I set the
RewriteBase
to it. Try setting it as/myproj/
instead of/
.我知道我迟到了,但这会对某人有所帮助。
检查重写引擎是否启用。
如果没有,启用重写引擎并重新启动服务器。
I know I am late, but this will help someone.
Check if rewrite engine is enabled.
If not, enable rewrite engine and restart server.
如果 wampserver 版本 2.5,则将 apache 配置更改为
httpd.conf(apache 配置文件):
从
到 ,删除 #
这对我来说工作正常
if The wampserver Version 2.5 then change apache configuration as
httpd.conf (apache configuration file):
From
To ,delete the #
this working fine to me