Welcome Guest, Not a member yet? Register   Sign In
Help with url routing
#1

[eluser]iambaz[/eluser]
Hi,

How do I change the routes.php so that url's do not call the method of a controller from it's second segment?

For example, I want the user to type a url like the following:

www.site.com/content/the-page-title

This would invoke the content controller and try to load 'the-page-title' as the method. I don't want the method to load though, I just want to run the content constructor and then use the second segment to identify the page in my database and load the content accordingly.

Many Thanks
#2

[eluser]Jônatan fróes[/eluser]
Code:
$route['content/(:any)'] = 'content/index/$1';

"content" Controller
Code:
...
function index($slug)
{
  $this->db->where('slug', $slug);
}
Is it what you need?
#3

[eluser]iambaz[/eluser]
Perfect - I had been writing it as:
Code:
$route['content/(:any)'] = 'content/$1';

Many thanks




Theme © iAndrew 2016 - Forum software by © MyBB