我正在尝试路由URL . 它的工作很好是localhost但不在服务器上工作 . 我在codeigniter中使用HMVC,其中'home'是模块,产品是controller . 如果我的网址结构如上所述,我想要路由 .
$1 - main category slug
$2 - brand category slug
$3 - model category slug
$4 - product ID
$5 = product title
Routes.php
$route['(:any)/(:any)/(:any)/(:num)/(:any)'] = 'home/product/$1/$2/$3/$4/$5';
其中home是目录的名称,而product是控制器 . 我的代码如下:
Product.php(控制器)
function _remap() {
$this->index();
}
function index() {
$segs = $this->uri->segment_array();
.
.
$product_id = $this->uri->segment(4);
.
.
}
1 回答
您收到404错误,因为您没有在url $ route ['(:any)/(:any)/(:any)/(:num)/(:any)'] ='home / product /中编写方法名称$ 1 / $ 2 / $ 3 / $ 4 / $ 5' ;