Welcome Guest, Not a member yet? Register   Sign In
Url params in routes
#1

[eluser]louis w[/eluser]
I have the following route set up:
Code:
$route['XML/foo(.*)']      = "foo$1?format=xml";

The route works, but errors. It seems like the re-routed uri becomes

/foo/bar?format=xml/

Notice the trailing slash. Is there a way to have url params work in routes?

Thanks.
#2

[eluser]Colin Williams[/eluser]
Hrm... that's not going to work like you think it is. By routing like that, you aren't magically creating a query string, your just telling CI to store the URI in a slightly different manner. And it's not CI that parses the URI for a query string, it's PHP (or, CGI, maybe). PHP won't know about this routing. You would have to parse the re-routed URI yourself.
#3

[eluser]louis w[/eluser]
Hmm, yea I see what you are saying. I guess I thought that CI would parse the string and take out params.

For the time being I just used $this->uri->segment(n) to get the first segment.

Thanks.
#4

[eluser]Colin Williams[/eluser]
Sure thing.




Theme © iAndrew 2016 - Forum software by © MyBB