404 error on simple controller |
Hi.
I previously used CI 3 and i am new to CI 4. My URL is accessible in : Code: http://localhost/my_git/ci4/public/ I have a simple controller like this PHP Code: <?php namespace App\Controllers; I have adjusted my app/Config/App.php : PHP Code: public $baseURL = 'http://localhost/my_git/ci4/public/'; My problem is : if i open Code: http://localhost/my_git/ci4/public/index.php/Cron/test/ I am redirected to Code: http://localhost/index.php/Cron/test But if i open Code: http://localhost/my_git/ci4/public/index.php/Cron/test/abcdefg It works correctly to the controller. I have not modified routes. Is there anything i should check? Thank you.
I would just set up a proper virtual host, don't develop your application within the public folder. It won't be hosted that way.
(08-01-2020, 06:27 AM)jreklund Wrote: I would just set up a proper virtual host, don't develop your application within the public folder. It won't be hosted that way.I use localhost (xampp), and i don't put any additional php files on "public" folder. My controller, model, and view is on "app" folder, if that what you meant ![]()
I mean you should not access your application by using the "public" folder in your url. You need a real domain.
https://www.cloudways.com/blog/configure...wordpress/ DocumentRoot = Path to your public folder.
(08-01-2020, 06:57 AM)jreklund Wrote: I mean you should not access your application by using the "public" folder in your url. You need a real domain.Ok thank you for the suggestion. Regarding error that i had, what codeigniter 4 setting that i should check? Thank you
No idea, it could actually be a routing error in Apache. So it's a waste of time debugging a development environment that dosen't mirror a real world deployment.
Just to add. Don't end your URL with a trailing slash. It will be redirected by htaccess. Trailing slashes matter when not on the base URL.
(08-01-2020, 08:40 AM)jreklund Wrote: No idea, it could actually be a routing error in Apache. So it's a waste of time debugging a development environment that dosen't mirror a real world deployment.Thank you for the help (08-01-2020, 09:47 AM)paulbalandan Wrote: Just to add. Don't end your URL with a trailing slash. It will be redirected by htaccess. Trailing slashes matter when not on the base URL.Thank's i think that is correct ! When i don't end URL with trailing slash, it works. Thanks for the help. |
Welcome Guest, Not a member yet? Register Sign In |