Skip to content
Advertisement

Why When I Click A href with base url the Page is 404 Not Found using codeigniter

Hello Everyone I want To Ask Why When Change Page using href i got 404 Not Found?

this is the path on my codeigniter

this config my base url

$config['base_url'] = 'http://localhost/Fenix/';

this is config for index page

$config['index_page'] = '';

and i already give .httacess on root

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

And href i want to click

<li class="nav-item"><a class="nav-link js-scroll-trigger" href="<?php echo base_url('controllers/Login_Controller')?>">Login</a></li>

And The Controller

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

class Login_Controller extends CI_Controller
{
     public function index()
    {
        $this->load->view('login');
    }
}

Can Anyone Help Me About This I’m Still New About Codeigniter

Advertisement

Answer

maybe you should use this

<li class="nav-item"><a class="nav-link js-scroll-trigger" href="<?php echo site_url('Login_Controller')?>">Login</a></li>

in codeigniter you have not to call a folder just controller and the function and when you call Login_Controller codeigniter will automatically read function index()

hope it help!

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement