简体   繁体   中英

Routing with codeigniter with customized URL

I have a controller named home, which is my default controller too. This is my path

http://192.168.1.100/FMP/mobile/home/index/suzuki-violin-school--6/102271

Now i am trying to rewrite the url as

http://192.168.1.100/FMP/mobile/suzuki-violin-school--6/102271

Where i need to remove both controller name and function name. So far i tried putting this in route.php

$route['(?!user|product).*'] = "mobile/home/index/";

But it takes all other methods in home controller and other controllers to the index function of home controller. Any thoughts on how can i achieve this?

Try this below code in end of your routes.php file

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

above route get two parameter and pass it into home page index function and your index function will be ass follow

public function index($parms1,$parms2)

Hope it will solve your problem. If not let me know. I'll happy to guide you through

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM