1
votes

I am trying to setup a new application using Codeigniter.

When i am defining the routes, i get an error 404 in all of them, except on default_controller.

I didn't change the .htaccess file and i can't access directly the controllers.

How do i fix this? I never had this error before on CI

HTACCESS

<IfModule authz_core_module>
    Require all denied
</IfModule>
<IfModule !authz_core_module>
    Deny from all
</IfModule>

Config

$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/CodeIgniter/core/';

$config['index_page'] = 'index.php';

Controller:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Utilizador extends CI_Controller {
    function __construct(){
        parent::__construct();
        $this->load->library('session');
    }

    public function index(){
        //print_r($this->Utilizador_model->teste());
        echo "pppp";
    }

    }


?>

Routes:

 $route['default_controller'] = 'pages';
    $route['404_override'] = '';
    $route['translate_uri_dashes'] = FALSE;
    $route['utilizador'] = 'utilizador';

HTML:

<div class="container">
  <div class="row">
    <div class="col-md-4 col-sm-6 col-xs-12 col-md-offset-4 col-sm-offset-3">
      <div class="bslf form">
        <form action="<?= base_url('utilizador') ?>" method="post">
          <h2 class="text-center">Login</h2>       
          <div class="form-group">
             <input type="text" class="form-control" placeholder="Username" required="required">
          </div>
          <div class="form-group">
            <input type="password" class="form-control" placeholder="Password" required="required">
          </div>
          <div class="form-group clearfix">
            <button type="submit" class="btn btn-primary pull-right">Log in</button>
          </div>       
        </form>
      </div>
    </div>
  </div>
</div>
1

1 Answers

1
votes

Update you .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>