Welcome Guest, Not a member yet? Register   Sign In
Can I remove the controller name from the url?
#1

[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
#2

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

[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!
#4

[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)
#5

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

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

[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
#8

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




Theme © iAndrew 2016 - Forum software by © MyBB