Function to verify URL and redirect to correct one