[bug] Rewrite maps correctly handle URLs with query strings attached to them.

The exact URL requested takes precedence, then the URL without the query string,
then parts of the directory structure from most specific to least specific.
Also cleaned up the phpdoc on that file a little.