Welcome Guest, Not a member yet? Register   Sign In
Removing controller part of URL
#1

[eluser]Sonolin[/eluser]
Greetings,

I am new to Codeigniter, but not to MVC frameworks (I worked with Django a lot before CodeIgniter). Today I started a new PHP project so I figured I'd give CI a try due to my enjoyable experience messing with it before.

Everything is going great so far, made a small little user auth library, and am authenticating user login fine. However, I have some trouble with the URLs. Codeigniter sets up URLs like so: "domain.com/controller/method". However, how exactly would I remove the "controller" part of the URL without resorting to .htaccess and keeping everything usable with CI's "redirect" function?

The thing is, since the main website will be done in codeigniter, I doubt my client would be satisfied with every URL having the controller name in it. The URLs would end up looking like this:

domain.com/controller/index
domain.com/controller/links
domain.com/controller/about
etc.

When I would much rather:

domain.com/index
domain.com/links
domain.com/about

I am sure this can be done, I am just stumped.

Indeed, I CAN put a route in routes.php. This works fine. HOWEVER, if I user "redirect" then CI redirects to the ugly URL.

Any solutions?
#2

[eluser]Adam Griffiths[/eluser]
If you redirect to the routed URL, it won't default back to the controller/method.

Well, that would be the theory. Or did I mis-read your post?
#3

[eluser]Sonolin[/eluser]
Ah great! Silly me, I completely looked over that one as I thought redirect corresponded to actual object/method relationships and not URI segments.

Thank you for the help




Theme © iAndrew 2016 - Forum software by © MyBB