Search code examples
controllerroutesseocodeigniter-2clean-urls

Creating dynamic urls in codeigniter


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 ?


Solution

  • 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