简体   繁体   中英

How to set up CodeIgniter site on localhost?

I'm new to CodeIgniter. I am trying to set up a CodeIgniter site on my local host. 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

     $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

  3. have set up the database

The working site URL looks like this: www.example.com/reservation/index.php

I have placed the site files in MyProjects/Project directory in local server. 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

$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 :

$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 :

define('ENVIRONMENT', 'development');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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