【问题标题】:codeigniter localhost internal server error 500codeigniter localhost 内部服务器错误 500
【发布时间】:2013-12-03 23:22:18
【问题描述】:

我正在使用 codeigniter 开始一个新项目。在 localhost 中设置工作文件夹时,我将以下 htaccess 文件放在我的项目根文件夹中,以便从 url 中删除 index.php

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1 

现在我收到如下错误消息

“内部服务器错误

服务器遇到内部错误或配置错误,无法完成您的请求。”

我的项目路径是 localhost/sc

在 config.php 文件中 我把下面这行

 $config['base_url']='http://localhost/sc';

服务器错误消息是“无效命令'RewriteEngine',可能拼写错误或由未包含在服务器配置中的模块定义”

我在 windows 平台上使用 wamp 服务器 请帮我解决这个问题

谢谢

【问题讨论】:

  • 你在apache中启用了重写模块吗?
  • 是的,我现在就这样做..但是现在找不到页面错误!!当我不在 url 中使用 index.php 时…….htaccess 文件是否有问题

标签: php .htaccess codeigniter wamp


【解决方案1】:

这个 .htaccess 脚本非常适合我。将它放在项目目录中的第一组文件夹中。与 index.php 文件同级

RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

可以使用以下路径/var/log/apache2/error.log 在 apache error.log 文件中检查错误 500

检查列出的最后一个错误并修复它。

【讨论】:

  • .htaccess 的完美文本,谢谢!
  • 你的最后一行(检查错误日志),大多数初学者可能已经忽略了......这是你回答中最有用的部分......
【解决方案2】:

看到这个问题:.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

本质上,您需要打开 mod_rewrite。这就是您收到 " Invalid command 'RewriteEngine' 错误消息的原因。

此外,由于您的项目路径位于/sc/,您需要将您的基础设置为/sc/

RewriteEngine On
RewriteBase /sc/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1 

并将 htaccess 文件放在/sc/ 文件夹中。

【讨论】:

    【解决方案3】:

    在你的 WAMP 中激活一个 rewrite_module。它默认禁用

    【讨论】:

      【解决方案4】:

      一年前我也遇到过同样的问题。 1. 首先,确保您的 Apache 服务器中启用了 mod_rewrite 模块(Apache -> Apache Modules -> Rewrite_module [Just select] 否则请参阅 wampserver 中 Apache 菜单下的“Apache 错误日志”以了解有关错误的更多信息) .不要浪费时间寻找其他解决方案。

      2。其次,这可能是因为 htaccess 规则。请将此基本代码行用于 htaccess。
       Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [QSA,L] 

      【讨论】:

        【解决方案5】:

        在 CodeIgniter 中,如果您调用的模型试图从不存在的表中获取值,您可能会遇到 500 - internal server error。

        【讨论】:

          【解决方案6】:

          在 wampserver 中激活 Rewrite_module Like Apache -> Apache Modules -> Rewrite_module [只需选择] 要不然 请参阅 wampserver 中 Apache 菜单下的“Apache 错误日志”以了解有关错误的更多信息

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2012-02-23
            • 2015-09-04
            • 2018-02-22
            • 2012-05-01
            • 1970-01-01
            • 1970-01-01
            • 2014-08-21
            • 2011-10-04
            相关资源
            最近更新 更多