handle rewiting on urls with query parameters correctly