2

I am new in framework please help to solve this. I am working in CodeIgniter. I want to have clean URLs like this: example.com/index.php/6/title

index.php/6 is a post ID and title is a Page title. I want to get data by post ID.

Controller function:

public function watch(){
            echo id;

        }

How to get this clean URL using routes. I am trying this route but it's not working:

$route['(:num)/(:any)'] = 'front_controller/watch/';
baikho
  • 5,203
  • 4
  • 40
  • 47
kidly
  • 21
  • 2

1 Answers1

0

Try this for routing to watch() function in Front_controller with 2 parameters id and title

$route['(:num)/(:any)'] = 'front_controller/watch/$1/$2';

Also you should accept 2 paramets in your controllers function too as :

function watch($id,$title)
{
    echo $id;
    echo $title;
}

Let me know in case of any queries.

Zeeshan
  • 803
  • 6
  • 15