1

I have a question about custom routes set in routes.php. Can route segment be optional?

Taking example from docs - 'blog/archive/<year:\d{4}>' => 'controller/action/path', can we make year token optional in url and still match route when someone vists blog/archive?

1 Answer 1

2

Short and sweet... I think you just need to add a second route.

'blog/archive' => 'controller/action/path',
'blog/archive/<year:\d{4}>' => 'controller/action/path'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.