0

i have codeigniter project. i am show the product page using router.php for the url change. Here i am facing some problems. the router code is here

Url                                 router.php code   
www.sitename.com/products/page/2 -> $route['products/page/(:num)'] = "products";
www.sitename.com/products/product-name -> $route['products/(:any)'] = "products/detail/$1";
www.sitename.com/products/product-categories -> $route['products/(:any)/(:num)'] = "products/selbygrp/$2";

the above code working fine for particular product detail view. But logically i have issues

problem: if i go to pagination links the router go to second route code . and also if select particular product group categories list it will go to second route code . what ever i gave it will go to second route line.

i know the reason for this. if products/ after anything it will take second route. but i don't need like this. the following urls i want

www.sitename.com/products/productname -> for product detailview
www.sitename.com/products/product-categories -> list product categories wise 
www.sitename.com/products/page/number -> show product list with pagenation 

i am stuck with this, if any possible to do with htaccess for this, give me the guidance thanks advance

4

3 回答 3

1

解决问题,动起来

$route['products/(:any)/(:num)'] = "products/selbygrp/$2";

以上

$route['products/(:any)'] = "products/detail/$1";
于 2013-06-18T15:29:06.413 回答
0

如果我对您的理解正确,您的链接会在分页的第二页后断开。当它在网址中粘贴此 /2 或任何其他数字时。

这就是我必须解决的问题,我昨晚也在做同样的事情。

在我的分页基础网址中,我将其切换到新网址

$config["base_url"] = base_url()."/products;

然后在我的路线中,我添加了另一条路线来适应分页。

$route['products/(:any)'] = "products/page/$1";
于 2013-06-18T16:14:49.397 回答
0

感谢大家给了我一个很好的答案。最后我找到了答案。答案就在这里,当 url 转到产品类别时,我为它创建了一个控制器,然后我像这样路由

url -> www.sitename.com/productgroup/groupname

route -> $route['productgroup/(:any)'] = "productgroup/selgrp/$1";

当我遇到产品类别时,上述路线被重定向到产品组控制器。所以分页问题也解决了。

我再次感谢每个给我很好的答案。

于 2013-06-19T07:11:32.887 回答