我定义了URL结构example.com/controller_name/method_name/product_id
,我希望URL结构为example.com/product_name
,但是在尝试编写example.com/product_name
或example.com/category_name
时遇到404错误。
我正在尝试写$route['(:any)/([a-zA-Z0-9]+)'] = '/products/details/$1';
,但它给出了404错误。
已经定义了以下代码,并且可以正常工作:
$route['(:any)'] = 'pages/view/$1';
$route['categories/posts/(:any)'] = 'category/posts/$1';
$route['categories/delete/(:any)'] = 'category/delete/$1';