如何在本地主机上设置 CodeIgniter 站点


How to set up CodeIgniter site on localhost?

我是CodeIgniter的新手。我正在尝试在本地主机上设置CodeIgniter站点。该网站在线运行良好。以下是我将网站迁移到本地主机的步骤。

  1. 编辑了应用程序/配置/congfig中的base_url.php

    $config['base_url']      = "http://localhost/MyProjects/Project/reservation/";
  2. 更改了应用程序/配置/数据库中的数据库连接设置.php以连接到本地主机数据库

  3. 已设置数据库

工作网站 URL 如下所示:www.example.com/reservation/index.php

我已将站点文件放在本地服务器的"我的项目/项目"目录中。我正在尝试访问

'http://localhost/MyProjects/Project/reservation/index.php'

但它返回空白页。(空体元素:)

以下是应用程序''配置''路由的内容.php

$route['default_controller'] = "admin";
$route['scaffolding_trigger'] = "";  
require_once BASEPATH.'database/DB'.EXT;
$db_obj = DB(); 
$new_branches = $db_obj->get('table_branches');
$new_branches = $new_branches->result();

foreach($new_branches as $branch){
   $route[trim($branch->url)]   = "reserve/index/".$branch->url;
   $route[trim($branch->url).'/']   = "reserve/index/".$branch->url;
   $route[trim($branch->url).'/admin']  = "admin";
}

谁能帮我解决这个问题?

第 3 行的路由文件中有一个错误:

$route['default_controller'] = "admin";
$route['scaffolding_trigger'] = "";  
==> employee_punchin|admin)'S*'] = "reserve/routing/$1";

应该修复它:

$route['(employee_punchin|admin)'S*'] = "reserve/routing/$1";

在 index.php 文件中,将 ENVIRONMENT 更改为 开发 以显示错误:

define('ENVIRONMENT', 'development');