I have links like this
http://example.com/search/texas
I want it to route to a controller search
and the URL should be
http://example.com/schools-in-texas
What I have done so far
On route
$route['search/(:any)'] = "search"; //search is a controller
On search controller I get the town name texas
using
$x = $this->uri->segment(2);
I want to query the database and use the result to open a search template with the url being http://example.com/schools-in-texas
where texas
is the search term.
I redirect to the url but doesn't load the data from database so it's not working as expected.
$url = $this->uri->segment(2);
redirect('schools-in-'.$url, 'refresh');
Can someone provide any idea how to achieve this?