• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Keep displaying "404 Page Not found" except default welcome message

Hi All,

Just installed Codeigniter 4 in Windows Server, but I've found that all custom pages displayed with a message "404 Page Not found" except the default welcome page could be viewed normally. I did not have any setting change yet. Please advise what's wrong with it. Thanks


Attached Files Thumbnail(s)

ok well , keeping it simple urls in web browser are linked to routes , which are linked to controllers.

So as default with no change to settings in app/Config/Routes.php there is :

$routes->get('/', 'Home::index');

that basically means a url in address bar of web browser with say something like (localhost) will use that route .

in app/Controllers/Home.php we have :

public function index()
return view('welcome_message');

So looking back at '/' which for all purposes equates to on apache local host

tells system use Class Home.php in Controllers and class method index()

index loads welcome_message which you will find at app/Views and is called welcome_message.php

now lets look at say a route i defined at one point :


that route would be invoked by a url such as :

it would look for Class Portfolio and its one of its methods called test

lets have look inside part of the test method:

$data = [
'title' => 'portfolio',
'info'=>'currently portfolio is empty',

echo view('header', $data);
echo view('info', $data);
echo view('footer',$data);


so its going to load /app/Views/header.php

in that order. header is used bu all pages and holds link to css file and title stuff
info.php is the middle section
footer.php is at the bottom and holds social media links etc.

now notice 'info'=>'currently portfolio is empty',

that gets passed to info.php and inside info.php I have a line

<?php echo $info; ?>
//which outputs on the web page : currently portfolio is empty

So basically the set up is of course MVC
models do database controllers do basic logic and load views.if you don't tell the system that views should be loaded and which ones they won't be

i guess your starting point is here : https://codeigniter4.github.io/CodeIgnit...index.html

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.