add strpos

add:
if (  strpos($url, '?&') !== false  ) $url = str_replace('?&','?', $url );