0 is not a valid url.
!== is good, but you can also unset/remove the query and fragment keys, than it is possible.
And can you move both functions away from the functions.php?