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?

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'
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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