Creating dynamic urls in codeigniter

风流意气都作罢 提交于 2019-12-12 01:57:36

问题


I am currently making a small CMS for a news agency. The admin will update the news in a interval of time. Now I want the url to be look like http://somedomain.com/apple-iphoe5c-released, not like http://somedomain.com/top-news/1. I have seen in gocart ( built in codeigniter ) , they have the url with the product name . How I am able to achieve this ?


回答1:


for this thing you have use the routes in ci which are as given

Consider the small example

$route['aboutus'] = "any controller is map to that name";

samplesite.com/aboutus [aboutus is controller] samplesite.com/contactus [contactus is controller]

$route['memberaccount/(:num)'] = "any controller is map to that name/$1";

samplesite.com/memberaccount/32

if still not getting try the above link https://www.codeigniter.com/userguide2/general/routing.html



来源:https://stackoverflow.com/questions/18760278/creating-dynamic-urls-in-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!