uri routing? |
[eluser]mikepuerto[/eluser]
Hello, I'm having trouble figuring this out, any help would be appreciated... So I have a controller called "Pages" that is set as the default controller and a route, that looks like this: Code: $route['(:any)'] = 'pages/$1'; This is currently allowing me to access "Pages" from the database with urls like: http://domain.com/some-page-name The problem is that with the above mentioned route, I can not access any other controllers. For example, I have a "Search" controller and upon accessing: http://domain.com/search I get a 404... Is it even possible to setup another route for "Search"(or any other) with the "Pages" route that I currently have? Thanks!
[eluser]Udi[/eluser]
What you did here is to define that - no matter what - activate Pages with the param. from the url -> example.com/pages/search And this is wrong. what you need to do is: Code: $route['pages/(:any)'] = 'pages/$1'; And then, when trying to enter example.com/Search you won't get any 404.
[eluser]mikepuerto[/eluser]
But this then prevents me from using - http://example.com/some-page-name. Is there no way to say, if /search is requested, display the search controller? I really don't want the url's for all the other pages to look like http://example.com/pages/some-page-name.
[eluser]Colin Williams[/eluser]
You need to explicitly route your other controllers first. Code: $route['search'] = "search"; You could route your static controllers automatically by iterating over the files in the controllers directory, or just list them out by hand.
[eluser]mikepuerto[/eluser]
OK! That worked! I had tried: Code: $route['search/(:any)'] = "search/$1"; I didn't realize I had to route just "search" as well. I also didn't realize that the order made a difference. Thanks so much! |
Welcome Guest, Not a member yet? Register Sign In |