Answer the question
In order to leave comments, you need to log in
How to specify in routing that id can contain letters but must necessarily end with a number?
The following paths need to work:
forum/forum-name.9 -> controller = forum, action = index, id = forum-name.9
forum/forum-name.9/edit -> controller = forum, action = edit, id = forum-name.9
forum/rules -> controller = forum, action = rules, id = null
I try like this
Route::set('default', '(/<controller>)((/<id>)(/<action>)))',
array(
'controller' => '[a-zA-Z_-]+',
'action' => '[a-zA-Z_-]+',
'id' => '[a-zA-Zа-я0-9.-]+',
))
->defaults(array(
'controller' => 'forum',
'action' => 'index',
'id'=>null
));
Answer the question
In order to leave comments, you need to log in
And it's even better to do
Route::set('default', '(/<controller>)((/(<name>.)<id>)(/<action>)))',
array(
'controller' => '[a-zA-Z_]+',
'action' => '[a-zA-Z_]+',
'name' => '[a-zA-Zа-я0-9-]+',
'id' => '\d+',
))
->defaults(array(
'controller' => 'forum',
'action' => 'index',
'name'=>null,
'id'=>0
));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question