简体   繁体   English

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

[英]How to set up CodeIgniter site on localhost?

I'm new to CodeIgniter.我是 CodeIgniter 的新手。 I am trying to set up a CodeIgniter site on my local host.我正在尝试在本地主机上设置 CodeIgniter 站点。 The site is working fine online.该网站在网上运行良好。 Here are the steps I have undertaken to migrate the site to my local host.以下是我将站点迁移到本地主机所采取的步骤。

  1. edited the base_url in the application/config/congfig.php编辑了 application/config/config.php 中的 base_url

     $config['base_url'] = "http://localhost/MyProjects/Project/reservation/";
  2. changed the database connect settings in the application/config/database.php to connect to localhost database更改 application/config/database.php 中的数据库连接设置以连接到 localhost 数据库

  3. have set up the database已经建立了数据库

The working site URL looks like this: www.example.com/reservation/index.php工作站点 URL 如下所示:www.example.com/reservation/index.php

I have placed the site files in MyProjects/Project directory in local server.我已将站点文件放在本地服务器的 MyProjects/Project 目录中。 I am trying to access我正在尝试访问

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

But it returns the blank page.但它返回空白页。 (Empty body element: ) (空身体元素:)

here are the contents of the application\\config\\routes.php这里是 application\\config\\routes.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";

}

Can anyone please help me with this?任何人都可以帮我解决这个问题吗?

There is an error in your route file at line 3 :您的路由文件中的第 3 行有错误:

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

should fix it:应该修复它:

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

in your index.php file, change the ENVIRONMENT to development to display errors :在您的 index.php 文件中,将 ENVIRONMENT 更改为 development 以显示错误:

define('ENVIRONMENT', 'development');

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

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