Code igniter url segment

56 views Asked by At

currently my website url is https://www.thefoolsbookie.com/main/inside?id=8 but I want this to be like this https://www.thefoolsbookie.com/nfl How can I do this?

1

There are 1 answers

2
mic On

Edit the application/config/routes.php file and add a new route for it

$route['nfl'] = 'main/inside';

It should be as simple as that :)

See https://ellislab.com/codeigniter/user-guide/general/routing.html for more examples.

Edit

I've worked with CI for a long time and I've never seen it use GET params in the routes file in that way. I'm not sure it is possible.

You could have it like $route['nfl'] = 'main/inside/8';

then in the main controller your inside method would look like:

public function inside($id)
{
    //$id would contain the ID of 8 when you go to 
    //https://www.thefoolsbookie.com/main/inside/8
    //or https://www.thefoolsbookie.com/nfl
}