簡體   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