I am trying to set up some custom routes and they are not working. It just hands me a 404 error. Is there something obviously wrong here?
c::set('routes', array(
array(
'pattern' => 'wires',
'action' => function() {
return page('/wire-instructions');
}
)
));
c::set('routes', array(
array(
'pattern' => 'security',
'action' => function() {
return page('/footer/security');
}
)
));
c::set('routes', array(
array(
'pattern' => 'bid',
'action' => function() {
return page('/vehicles-homes/socu-owned-vehicles');
}
)
));
Yes, you have to put all routes into a single array, multiple c::set()
commands will not work. Also, remove the slashes before the name of the page; if you want to reroute to child pages of the pattern page, include it in the path.
c::set('routes', array(
array(
'pattern' => 'wires',
'action' => function() {
return page('wire-instructions');
}
),
array(
'pattern' => 'security',
'action' => function() {
return page('footer/security');
}
),
array(
'pattern' => 'bid',
'action' => function() {
return page('vehicles-homes/socu-owned-vehicles');
}
)
));
This would be a good example to include in the documentation for routing. Thanks!
I agree, this information is missing. I’ll add it asap.