code: def is_up_url(url, allow_redirects=False, timeout=5):
      r
      if not isinstance(url, basestring) or '.' not in url:
          return False
      normalized_url = prepend_http(url)
      session = requests.Session()
      session.mount(url, HTTPAdapter(max_retries=2))
      try:
          resp = session.get(normalized_url, allow_redirects=allow_redirects, timeout=timeout)
      except ConnectionError:
          return None
      except:
          return None
      if resp.status_code in (301, 302, 307) or resp.headers.get('location', None):
          return resp.headers.get('location', None)  # return redirected URL
      elif 100 <= resp.status_code < 400:
          return normalized_url  # return the original URL that was requested/visited
      else:
          return False
docs: r""" Check URL to see if it is a valid web page, return the redirected location if it is
  
      Returns:
        None if ConnectionError
        False if url is invalid (any HTTP error code)
        cleaned up URL (following redirects and possibly adding HTTP schema "http://")
  
      >>> is_up_url("duckduckgo.com")  # a more private, less manipulative search engine
      'https://duckduckgo.com/'
      >>> urlisup = is_up_url("totalgood.org")
      >>> not urlisup or str(urlisup).startswith('http')
      True
      >>> urlisup = is_up_url("wikipedia.org")
      >>> str(urlisup).startswith('http')
      True
      >>> 'wikipedia.org' in str(urlisup)
      True
      >>> bool(is_up_url('8158989668202919656'))
      False
      >>> is_up_url('invalidurlwithoutadomain')
      False