Reputation: 949
I found out that my routes are not working at all, when I type in the route it says 'Object not found'. It loads the index function by default and that works , but the routes won't.
routes:
$route['default_controller'] = 'personeelcontroller';
$route['personeelcontroller/editPersoon'] = 'maincontroller/editPersoon';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['personeelcontroller/onInit'] = 'personeelcontroller/onInit';
$route['personeelcontroller/index'] = 'personeelcontroller/index';
controller:
class PersoneelController extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('PersoneelModel');
$this->load->model('ProjectModel');
$this->load->helper('url_helper');
}
public function index(){
$data['personeel'] = $this->PersoneelModel->getPersonen();
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->view('urls/home' , $data);
}
public function onInit()
{
$data['projecten'] = $this->ProjectModel->GetProjecten();
$this->load->view('urls/projects' , $data);// laad deze view wanneer methode wordt opgeroepen
}
public function editPersoon(){
$this->load->helper('form');
$this->load->library('form_validation');
$this->form_validation->set_rules('id', 'Id', 'required');
$this->form_validation->set_rules('name', 'Name', 'required');
if ($this->form_validation->run() === FALSE)
{
$this->load->view('urls/failed');
}
else
{
$this->PersoneelModel->editPersoon();
$this::index();
}
}
}
Upvotes: 2
Views: 1654
Reputation: 514
check if there is any .htaccess file in root. if not add the .htaccess file and write the following code in .htaccess file
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Upvotes: 1