phpapacheparameter-passingmultiviews

Any parameters passed with multiviews?


Given /group/14/ with multiviews enabled on group, I get a redirect to /group.php, but is 14 passed to PHP in any form besides the $_SERVER variables? Ideally, I could get this in a query string of some kind. I read parts of the Content Negotiation article on it, but I can't seem to find any indication that this is the case.

Edit: For whatever reason, that above wasn't clear. Let me try again.

I have group.php which wants a group id like group.php?id=14. Normally, I'd use URL rewriting to have /group/14/ rewrite to /group.php?id=14. However, in this case I have multiviews enabled, and the URL rewrite does not trigger. So /group/14/ DOES get sent to /group.php but does not send 14 as a query string. Is there anyway besides parsing 14 from the $_SERVER['REQUESTED_URI'] that I can get it with multiviews enabled?


Solution

  • This rule will match:

    RewriteRule ^group.php/(.*)$ ./group.php?id=$1 [L,NE]
    

    Having Multiviews enabled transform the group/14 to group.php/14 (where ${PATH_INFO} is '/14', which is smarter than other $_SERVER vars, but this is another problem). After this first apache internal rewrite (from multiviews) the rewriteRule are run again, and you can then capture the group.php/14.