Search code examples
.htaccessfat-free-framework

howto use fatfree php framework without rewrite engine


I'm not able to use an htaccess for my project therefore clean URLs doesn't work for routing. Is there a way to to use query params instead?

example

myf3project.net/user/show isn't possible. Instead I want to do something like this:

  • myf3project.net?path=user/show or
  • myf3project.net?view=user&action=show

Solution

  • You can also overwrite the $_SERVER['REQUEST_URI'] for this purpose:

    $f3->route('GET /user', function ($f3) { echo "user"; });
    $f3->route('GET /user/@action',function($f3,$params){ 
      echo "user->".$params['action']; 
    });
    
    if ($f3->exists('GET.path',$path))
        $f3->URI = $f3->BASE.'/'.$path;
    
    $f3->run();
    

    and then just open http://myf3project.net?path=user/show