I am trying to create a new site under xampp (php 8.2) with CodeIgniter 4.6(the latest). Here are what I did:
run cmd: composer create-project codeigniter4/appstarter c46 under folder htdocs
update baseURL in App.php like below
public string $baseURL = 'http://localhost:988/c46/'; // also tried with public at end
Now, I can go to http://localhost:988/c46/public/ to see the default welcome page (the one from Home controller index method). all good so far.
I added a new function in controller Home.php
public function test(): string
{
return 'ok';
}
Here is my issue, I could not access the page home/test. Seems only the default controller and method is working. I tried:
- http://localhost:988/c46/public/home/test -- 404 message displayed
- http://localhost:988/c46/public/index.php?home/test -- this goes to the default page
- http://localhost:988/c46/public/index.php/home/test -- 404 message displayed
I also tried to change .htaccess file in public folder RewriteBase to below, both not working
RewriteBase /c46
RewriteBase /c46/public
How can I access the new page/method in controller? what are the changes I need to make to get this work?
app/Config/Routes.php? Try adding$routes->get('/home/test', 'Home::test');