php codeigniter localhost 内部服务器错误 500

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20087947/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:51:48  来源:igfitidea点击:

codeigniter localhost internal server error 500

php.htaccesscodeigniterwamp

提问by Chinthu

I am starting a new project in codeigniter. While setting up work folder in localhost i put the following htaccess file in my project root folder for remove index.php from the url

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

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

now i am getting the error message as follows

现在我收到如下错误信息

"Internal Server Error

“内部服务器错误

The server encountered an internal error or misconfiguration and was unable to complete your request."

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

my project path is localhost/sc

我的项目路径是 localhost/sc

in the config.php file i put the following line

在 config.php 文件中,我添加了以下行

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

server error message is " Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration"

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

I am using wamp server in windows platform please help me to solve this problem

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

Thank you

谢谢

回答by shimanyi

This .htaccess script works perfectly for me. Place it within the first set of folders inside your project directory. Same level as the index.php file

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

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

The error 500 can be checked on the apache error.log file using the following path /var/log/apache2/error.log

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

Check the last error listed and fix it.

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

回答by Jon Lin

See this question: .htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

请参阅此问题:.htaccess: Invalid command 'RewriteEngine',可能拼写错误或由未包含在服务器配置中的模块定义

Essentially, you need to turn on mod_rewrite. That's why you're getting the " Invalid command 'RewriteEngine'error message.

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

Additionally, since you're project path is in /sc/you need to set you base to /sc/:

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

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

And place the htaccess file in the /sc/folder.

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

回答by Rafik Bari

Activate a rewrite_module in your WAMP. It comes disabled by default

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

回答by Krupal Patel

I had the same issue a year ago. 1. First and foremost, make sure that mod_rewrite module is enabled in your apache server ( Apache -> Apache Modules -> Rewrite_module [Just select] Or else See "Apache error log" under Apache Menu in wampserver to know more about the error). Don't waste time for other solution.

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

2. Secondly, that might be because of htaccess rules. Kindly, use this basic line of code for htaccess.
 Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/ [QSA,L] 

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

回答by Jaffar

Activate Rewrite_module in wampserver Like Apache -> Apache Modules -> Rewrite_module [Just select] Or else See "Apache error log" under Apache Menu in wampserver to know more about the error

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

回答by Piyush Balapure

In CodeIgniter, If you are calling a model that tries to fetch values from a table that doesn't exist, you may face a 500 - internal server error.

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