4

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!!!

Mr.Happy
  • 517
  • 1
  • 9
  • 25

3 Answers3

0

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';
Yaseen Ahmad
  • 1,807
  • 5
  • 25
  • 43
R.Surya
  • 184
  • 12
0

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){…}
massisenergy
  • 1,764
  • 3
  • 14
  • 25
Jens T
  • 1
0

In the routes.php make sure you are using this line after your other routes which starts with some text.

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

Also make sure your slug for each article is unique in your database. There is no other way to send hidden id from get request.

Ankur Singh
  • 161
  • 1
  • 6