Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter - route - Error 404
#1

Hello,



I have a "routing" problem on CodeIgniter 4.2.7.

My home page is displayed well, the page also reloads well when I click on "home" in my menu, on this side there is no problem, however when I want to access another page I have the message error following "Error 404".



Here is my controller:



Code:
class c_accueil extends BaseController
{
    public function index()
    {
        $data['titre'] = "Accueil";
        return
            view('v_menu')
            . view('v_accueil',$data)
            . view('v_footer');
    }
    public function espaceNintendo()
    {
        $data['titre'] = "Espace Nintendo";
        return
            view('v_menu')
            . view('v_espaceNintendo', $data)
            . view('v_footer');
    }



Here is my base url:

Code:
public $baseURL = 'http://localhost:63342/ProjetWeb';



Here is my route:


Code:
$routes->get('/', 'c_accueil::index');
$routes->get('/public/espaceNintendo', 'c_accueil::espaceNintendo');



Here is my view (v_menu) :

Code:
<?=anchor(base_url().'/public/', 'Accueil')?>
<?=anchor(base_url().'/public/espaceNintendo', 'Espace Nintendo')?>



So "Accueil" works fine but not "espaceNintendo"


Url of my home page which works well:


http://localhost:63342/ProjetWeb/public/

However, the URL as soon as I click on "Espace nintendo" is this:

http://localhost:63342/ProjetWeb/public/espaceNintendo


But it gives me "error 404".

Do you have any idea where the problem comes from?



My helpers are well loaded on my base_controller:


Code:
protected $helpers = ['html', 'form', 'url'];



I tried many things but none solved my problem
Reply
#2

You need to know about Base URL, URI path and route.
See https://codeigniter4.github.io/CodeIgnit...-structure

Your baseURL is http://localhost:63342/ProjetWeb/public/.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB