views:

126

answers:

1

I'm trying to get 'clean' PathInfo style URLs with query string parameters working on PHP 5.3 and IIS 5.1 using FastCGI. I've found that I can use:

(1) http://www.example.com/index.php?/path/to/foo/

but not:

(2) http://www.example.com/index.php/path/to/foo/ (Note the missing ?)

Which isn't a big issue until I want to mix URLs with a query string like:

(3) http://www.example.com/index.php?/path/to/foo/?color=blue&size=small

That makes my $_GET look like:

Array
(
    [/myapp/foo/bar?colour] => blue
    [size] => small
)

Is there way to get a URL scheme like (4) below to work, and with $_GET being populated correctly on IIS 5.1?

(4) http://www.example.com/index.php/path/to/foo/?color=blue&size=small

P.S. - I remember being able to do this before, but I suspect I was using Apache at the time and not IIS. Unable to use Apache for this. However the production server has IIS7 (I only have IIS 5.1 on my machine).

A: 

For (3), you simply need to treat the query-string as a single piece of text. You should not be using $_GET - you should be using the QUERY_STRING environment variable directly, instead. You should get /path/to/foo/?color=blue&size=small.

For (4), you should concatenate the PATH_INFO and QUERY_STRING environment variables, joined with a ?, and use that value. Again, you should get /path/to/foo/?color=blue&size=small. This is because PATH_INFO has /path/to/foo and QUERY_STRING has color=blue&size=small.

Justice
Thanks! This works great. For IIS5, since it requires the 'index.php?' and not simply 'index.php', I also needed to split the on the '?', and then use parse_str on the result.
Mario