Route results in 404 Not Found

Asked

Viewed 435 times

1

I was following the Codeigniter startup tutorial when I came across a problem with routes.

the route file is with the following routes:

$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

$route['news/create'] = 'news/create';
$route['news/(:any)'] = 'news/view/$1';
$route['news'] = 'news';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';

An example of a controller could be Pages:

class Pages extends CI_Controller
{
    public function view($page = 'home')
    {
        if ( ! file_exists(APPPATH . 'views/pages/' . $page . '.php'))
            show_404();

        $data['title'] = ucfirst($page);

        $this->load->view('templates/header', $data);
        $this->load->view('pages/'.$page, $data);
        $this->load->view('templates/footer', $data);
    }
}

When called by default_controller it runs normally, but when I try to enter a different route a Not Found of Apache.

I’ve already checked if all classes are capitalized, the rewrite module is active, and in config.php I just changed the:

$config['base_url'] = 'http://estudo.local/ci/';

The .htaccess:

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

What would be the problem?

  • How’s the . htaccess file?

  • Didn’t forget to put it on?

  • 1

    I put him in the question, I didn’t change anything in him because in the tutorial it didn’t say anything about him so I trusted for his an official tutorial.

1 answer

2


Puts the . htaccess file as follows:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.