I'm trying grocery crud example in codeigniter framework, but I have problems with href links.
I type localhost/name_of_my_site/employees then I can see the list of records of employee table.
But if I press "Add record" button, then the href is localhost/name_of_my_site/add. So I get 404 error.
If I manually correct the url from localhost/name_of_my_site/add to localhost/name_of_my_site/employees/add then I can see add form.
Have I got a problem with routes?? My default controller is called Main.php.
Thank you in advance,
Mariana
.htaccess
#php_value memory_limit 64M
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond $1 !^(index\.php|img|robots\.txt|favicon\.ico|uploadify|uploads|fonts|plugins/|application/assets/|files_videos|assets|application/libraries/)
RewriteRule ^(.*)$ index.php?/$1 [L]
#RewriteCond %{HTTPS} on
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
config.php
$config['base_url'] = "http://localhost/name_of_my_site/";
$config['index_page'] = '';
route.php
$route['default_controller'] = "Main";
$route['(.*)'] = 'Main/$1';
main.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Main extends CI_Controller {
function __construct()
{
parent::__construct();
/* Standard Libraries of codeigniter are required */
$this->load->database();
$this->load->helper('url');
/* ------------------ */
$this->load->library('grocery_CRUD');
}
public function index()
{
echo "<h1>Welcome to the world of Codeigniter</h1>";//Just an example to ensure that we get into the function
die();
}
public function employees()
{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('employees');
$crud->unset_export();
$crud->unset_print();
$output = $crud->render();
$this->load->view('our_template', $output);
}
function _example_output($output = null)
{
$this->load->view('our_template.php',$output);
}
}