# request.is_secure() #若是是https則爲True,反之爲False http = urlsplit(request.build_absolute_uri(None)).scheme #得到當前的HTTP或HTTPS host = request.META['HTTP_HOST'] #獲取當前域名 shorturl = http + '://' + host + '/' + shorturl1 + '/' # shorturl = re.search(r'http[s]?://[^/]+', url).group()+'/'+shorturl1+'/'