• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom Routes

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?

(: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.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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