1
votes

I am trying to route the URL. Its working nice is localhost but not working in server. I am using HMVC in codeigniter where 'home' is the module and product is controller. I want to routes if my url structure comes like mentioned.

$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';

In which home is the name of directory and product is controller. And my code is as follows:

Product.php (Controller)

  function _remap() {
    $this->index();
  }

function index() {
    $segs = $this->uri->segment_array();
    .
    .
    $product_id = $this->uri->segment(4);
    .
    .
}
1
how about site_url()? - Renjith V R
Which type of error are you getting? - Silvio Delgado
Have you tried putting function after product $route['(:any)/(:any)/(:any)/(:num)/(:any)'] = 'home/product/index/$1/$2/$3/$4/$5'; - Mr. ED
I am getting 404 error. - user254153

1 Answers

1
votes

You are getting 404 error because you have not written method name in url $route['(:any)/(:any)/(:any)/(:num)/(:any)'] = 'home/product/$1/$2/$3/$4/$5';

It should be like this

$route['(:any)/(:any)/(:any)/(:num)/(:any)'] = home/product/index/$1/$2/$3/$4/$5';