Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Question about routers configuration
  • Hey,
    I have a question about routing. in config/routes.php :
    '_root_'   => 'public/index',
    '_404_'   => 'public/404',
    
    // ADMIN Routes
    'adm'   => 'admin/dashboard', // Admin Dashboard
    'adm/(:any)'  => 'admin/$1',   // Admin Controllers
     
    // API Routess
    'api'    => 'api/404',   // Return status 404 and a null body
    'api/(:any)'  => 'api/$1',   // API Controllers
    

    What can I have to do to catch all requests ( not admin, not api and not 404 ) and route to "public/index/$1" ??? I cannot insert '(:any)' => 'public/index/$1' because override 404 route, right?
  • What you're saying is that you want to route all requests for controller/methods that can be resolved to a specific controller/method? Isn't that a bit strange?
  • If I would something like :
    http://domain.ext/blog/posts
    http://domain.ext/category1/pages
    .... Where all after domain.ext is dynamic ( from db ).
    But I would also a domain.ext/adm that redirect to admin panel What do you suggest?
    Thank you!!
  • The normal approach for dynamic routing is that you route everything to your front controller, have it sort out the routing, and if something is not found, throw a \Request404Exception. The 404 exception is caught in your index.php, and hardcoded loads the _404_ route.
  • The normal approach for dynamic routing is that you route everything to your front controller

    ok, so ... What I have to write in routes.php to route everithing to my "public" controller? (:any) => public/index/$1 ?
  • That should work. In my case _root_, _404_ and :any all point to the same controller, as I do the 404 handling internally, I don't rely on Fuel's 404 views.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion