CodeIgniter Forums
Can I remove the controller name from the url? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Can I remove the controller name from the url? (/showthread.php?tid=18441)



Can I remove the controller name from the url? - El Forum - 05-06-2009

[eluser]Unknown[/eluser]
Hello, CodeIgniter forums!

I have run into an interesting problem, and I can't figure out how to solve it elegantly.

My CodeIgniter installation is not in my web root, but in a sub folder called dvd_collection. My idea was to use urls like "dvd_collection/browse", "dvd_collection/search" etc. The problem is that the controller name needs to come before the functions, producing the, to me, ugly urls "dvd_collection/controller_name/browse" and "dvd_collection/controller_name/search" instead.

I have come up with two ideas to solve this, but I don't like either of them.

1. Moving CodeIgniter to my root, making it the center of my whole website, which I would not like.
2. Creating a contoller for each and every function. This is not only ugly, but the same problem with double url parts would arise with "controller_name/function_name" instead of "folder_name/controller_name" whenever I want to pass parameters to a function (the first parameter after the controller name is always the function name, I believe).

Have anyone had similar problems, or is there a solution I haven't found out about?

Thanks for any help.

//Johan


Can I remove the controller name from the url? - El Forum - 05-06-2009

[eluser]Dam1an[/eluser]
I think what you need is routing


Can I remove the controller name from the url? - El Forum - 05-06-2009

[eluser]Unknown[/eluser]
That seems like exactly what I need!
I'm really new to CodeIgniter and I'm still working my way through the user guide, so thank you Dam1an for the quick and friendly response. CodeIgniter is getting better and better the more I learn!


Can I remove the controller name from the url? - El Forum - 05-06-2009

[eluser]Dam1an[/eluser]
you're welcome
Its not CI getting better (unless the just made a new release), but its you thats getting better with it (a few words of wisdom/encouragement)


Can I remove the controller name from the url? - El Forum - 05-07-2009

[eluser]TheFuzzy0ne[/eluser]
...And welcome to the CodeIgniter forums!


Can I remove the controller name from the url? - El Forum - 05-07-2009

[eluser]jdfwarrior[/eluser]
Dam1an and Fuzzy are so warm and sweet. Makes you just wanna eat em up doesnt it? Smile


Can I remove the controller name from the url? - El Forum - 05-07-2009

[eluser]Dam1an[/eluser]
I've managed to avoid being eaten up until now, I'll be damned if I'm gonna get eaten now
Besides... if you (or someone else) eat me, I won't be able to help anymore


Can I remove the controller name from the url? - El Forum - 05-07-2009

[eluser]slowgary[/eluser]
Why not just call your controller "dvd_collection"?