Welcome Guest, Not a member yet? Register   Sign In
Custom Routes
#1

(This post was last modified: 02-26-2020, 03:59 AM by lucasrohers.)

Hello friends, CI4 was launched and it is simply, excellent. I am updating my projects, but I have some difficulty in the routes.
I have a website with a BLOG system and user login. Everything works fine, however, I can't do the correct routing for the news to access only with / url-NOTICIA
I managed to make it work as follows:
$routes->get('/', 'Home::index');
$routes->add('(:any)', 'Home::post/$1');


However, all my other controllers that are after domain/, for example domain/login or domain/ settings are automatically redirected to the home page. I tried to add:
$routes->get('settings', 'Settings::index');


And then the page accessed, but he has no access to the other methods inside the controller. Besides that, I tried to add a route for the methods, and it didn't work.

* I followed the documentation .. but .. Where am I going wrong?
Reply
#2

(:any) catches literally anything, so you've essentially said "anything that is not example.com/ goes to Home::post/$1". You will either need to loosen up your rule or add some more explicit routes first.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB