• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
404 - File Not Found

#1
Hi all,
I'm running the ci_news app on my local network:
Code:
php spark serve --host 192.168.1.15


CodeIgniter CLI Tool - Version 4.0.4 - Server-Time: 2020-11-03 09:21:28am
CodeIgniter development server started on http://192.168.1.15:8080
Press Control-C to stop.
[Tue Nov  3 10:21:28 2020] PHP 7.4.12 Development Server (http://192.168.1.15:8080) started
[Tue Nov  3 10:26:26 2020] 192.168.1.5:54946 Accepted
[Tue Nov  3 10:26:26 2020] 192.168.1.5:54945 Accepted
[Tue Nov  3 10:26:26 2020] 192.168.1.5:54945 Closing


I can load the default page into a browser:

http://192.168.1.15:8080/
Welcome to CodeIgniter 4.0.4

But after going through the tutorial I cannot  load the pages.

http://192.168.1.15:8080/pages
404 - File Not Found

[Tue Nov  3 10:45:32 2020] 192.168.1.5:55074 Accepted
[Tue Nov  3 10:45:32 2020] 192.168.1.5:55075 Closing
[Tue Nov  3 10:45:32 2020] 192.168.1.5:55074 [200]: GET /favicon.ico
[Tue Nov  3 10:45:32 2020] 192.168.1.5:55074 Closing


It's throwing the exception called from Controllers/Pages.php:
throw new \CodeIgniter\Exceptions\PageNotFoundException("hmm.. not found: ". $page);

Do you have any advice?
thank you.
Reply

#2
You need to set your app/Config/app.php base_url

PHP Code:
http://192.168.1.15:8080/ 

You should also edit the env file in the root with index.php end add your base url there also.

Change the env CI_ENVIRONMENT = development save the file as .env

Make sure that you setup the routes for the tutorials.

app/Config/Routes.php add to the bottom below the home route.

PHP Code:
$routes->match(['get''post'], 'news/create''News::create');
$routes->get('news/(:segment)''News::view/$1');
$routes->get('news''News::index');
$routes->get('(:any)''Pages::view/$1'); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
(11-04-2020, 12:02 AM)InsiteFX Wrote: You need to set your app/Config/app.php base_url

PHP Code:
http://192.168.1.15:8080/ 

You should also edit the env file in the root with index.php end add your base url there also.

Change the env CI_ENVIRONMENT = development save the file as .env

Make sure that you setup the routes for the tutorials.

app/Config/Routes.php add to the bottom below the home route.

PHP Code:
$routes->match(['get''post'], 'news/create''News::create');
$routes->get('news/(:segment)''News::view/$1');
$routes->get('news''News::index');
$routes->get('(:any)''Pages::view/$1'); 
I agree with your opinion
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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