4
votes

I am beginner on Codeigniter so I need help.

I am making blog site with Codeigniterand I don't know how to hide controller class, and ID from URL.

Like I have generated following URL: http://localhost/codeigniter/index.php/content/some-title/123.

  1. content is my controller class name.
  2. some-title is my article title.
  3. 123 is my article id.

I want to keep only title to show.

For example: http://localhost/codeigniter/index.php/some-title.

Any help would be appreciated!!!

2
are you using nginx or apache? - Daniel Krom
In application/config/routes.php. $route['some-title/(:any)'] = 'content/some-title/$i'; - Prem Bikram Limbu
This is possible but you will need an extra controller for that let me know if want to add the extra controller and still not done that task so i will answer - Yaseen Ahmad

2 Answers

0
votes

You has add your link config/routes.php

http://localhost/codeigniter/index.php/content/some-title/123

Ex: $route ['some-title/(: any)']  = 'content/some-title/$123';
0
votes

You can do this:

$route['(:any)'] = 'content/view/$1';

and in your content controller you must have a method like the one follow:

public funtion view($pagetitle){…}