def urlcheck(short, short1=None, short2=None): if short1 is not None: short = short + "/" + short1 if short2 is not None: short = short + "/" + short2 match = Url.match(short.lower()) if match is None: return "No match found" match.hits_record(request.remote_addr) # finally redirect return redirect(match.dest, code=302)