繁体   English   中英

codeigniter localhost 内部服务器错误 500

[英]codeigniter localhost internal server error 500

我正在 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服务器请帮我解决这个问题

谢谢

这个 .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: Invalid command 'RewriteEngine',可能拼写错误或由未包含在服务器配置中的模块定义

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

此外,由于您的项目路径在/sc/您需要将 base 设置为/sc/

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

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

在 WAMP 中激活 rewrite_module。 它默认禁用

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

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

在 CodeIgniter 中,如果您调用的模型试图从不存在的表中获取值,您可能会遇到 500 - 内部服务器错误。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM