![]() |
Keep displaying "404 Page Not found" except default welcome message - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Keep displaying "404 Page Not found" except default welcome message (/showthread.php?tid=76953) |
Keep displaying "404 Page Not found" except default welcome message - joanne.leung - 07-06-2020 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 Joanne RE: Keep displaying "404 Page Not found" except default welcome message - captain-sensible - 07-07-2020 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 127.0.0.1 (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 127.0.0.1 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 : $routes->get('test','Portfolio::test'); that route would be invoked by a url such as : 127.0.0.1/test 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', 'date'=>$date ]; echo view('header', $data); echo view('info', $data); echo view('footer',$data); } so its going to load /app/Views/header.php /app/Views/info.php /app/Views/footer.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/CodeIgniter4/tutorial/index.html |