what about changing this code to be:

    r->raw_uri = r->uri;