remove controller from url? |
[eluser]thebwit[/eluser]
Ok so I built a massive controller to handle all the requests. It works the way I want it to which is fine. However here's the problem. Currently urls look like http://mysite.com/page/news/Breaking News or mysite.com/page/interview/Megan Fox I don't want to display "page" in my urls. Anyone have an idea how to accomplish this without hacking any core files?
[eluser]Chad Fulton[/eluser]
I think you will want to use the Routing feature. Something like: Code: $routes['(:any)'] = 'page/$1'; Although it sounds like you're not interested in a critique of the "one big controller" approach, I do want to mention that it will not be scalable or (probably) maintainable in the long run. You should think about breaking it up, maybe.
[eluser]thebwit[/eluser]
Ahh thanks for that. I knew I had seen something somewhere about this. I do know about the pro's and cons of one big controller and I think that in this implementation it is fine as there is a fixed limit of functions. Thanks again.
[eluser]thebwit[/eluser]
The $1 doesn't work. Is there something I am missing? Keep in mind that of my url: mysite.com/page/news/Breaking That news is still a function of the page controller.
[eluser]thebwit[/eluser]
Ok after some more messing around and re-reading the routes stuff in the user guide I got it working. Thanks again for pointing me in the right direction.
[eluser]slowgary[/eluser]
Did you put Chad's route into your routes.php file? It looks right to me, based on the routing section of the user guide.
[eluser]thebwit[/eluser]
i had to do something a little more specific. I put: Code: $oute['news/(:any)'] = "page/news/$1"; This way also if I split things up to not be a giant controller I just have to change the route and I am good. |
Welcome Guest, Not a member yet? Register Sign In |