You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Guidance from user manual
Note: If you use back-references you must use the dollar syntax rather than the double backslash syntax. A typical RegEx route might look something like this:
$routes->add('products/([a-z]+)/(\d+)', '$1::id_$2');
There isn't any variable variable substitution done for the controller name. So - it's not that it doesn't work, it just doesn't work for the controller. And that's by design. To allow any controller in the system to be ran based on user input like that is asking for a giant security hole.
Thanks for the clear feedback. I understand this was possible in the previous version. The user guide indicates this is possible and might benefit from a correction on this item: https://codeigniter4.github.io/userguide/incoming/routing.html
$routes->add('products/([a-z]+)/(\d+)', '$1::id_$2');
Back-references not working in route
Guidance from user manual
Note: If you use back-references you must use the dollar syntax rather than the double backslash syntax. A typical RegEx route might look something like this:
$routes->add('products/([a-z]+)/(\d+)', '$1::id_$2');
Code
Routes.php file:
$routes->get('products/([a-z]+)/(:num)','$1::view/$2');
Action
Go to http://site.test/products/trucks/5 on local development machine
Expected behaviour (based on user manual)
Load view() method on Trucks controller called with the numerical product id.
Actual behaviour
404 Error
Controller or its method is not found: \App\Controllers$1::view
The back-reference is not being converter from $1 to Trucks
CodeIgniter 4 version
v4.0.0-alpha.5
Affected module(s)
\Codeigniter\Router
Context
The text was updated successfully, but these errors were encountered: