nikic / FastRoute

Fast request router for PHP
Other
5.13k stars 445 forks source link

Wild Card Routes #229

Closed mav2287 closed 3 years ago

mav2287 commented 3 years ago

Is there a way to setup fast route to catch all sub routes of a specific route? So for example:

$r->addRoute('GET', '/CSS/*', 'handler');
function handler() {
    echo "If you are at example.com/CSS or examples.com/CSS/dir/project/sample this all gets handled here";
}
lcobucci commented 3 years ago

@mav2287 you may use a catch-all regex on a parameter:

$r->addRoute('GET', '/CSS/{path:.*}', 'handler');
mav2287 commented 3 years ago

Thanks for the response. That might be useful to have on the Read Me.