def redirect_to_url(req, url, redirection_type=None, norobot=False):
url = url.strip()<EOL>if redirection_type is None:<EOL><INDENT>redirection_type = apache.HTTP_MOVED_TEMPORARILY<EOL><DEDENT>from flask import redirect<EOL>r = redirect(url, code=redirection_type)<EOL>raise apache.SERVER_RETURN(r)<EOL>del req.headers_out["<STR_LIT>"]<EOL>req.headers_out["<STR_LIT>"] = "<STR_LIT>""<STR_LIT>"<EOL>req.headers_out["<STR_LIT>"] = "<STR_LIT>"<EOL>if norobot:<EOL><INDENT>req.headers_out[<EOL>"<STR_LIT>"] = "<STR_LIT>"<EOL><DEDENT>user_agent = req.headers_in.get('<STR_LIT>', '<STR_LIT>')<EOL>if '<STR_LIT>' in user_agent or '<STR_LIT>' in user_agent:<EOL><INDENT>req.status = <NUM_LIT:200><EOL>req.content_type = '<STR_LIT>'<EOL>if req.method != '<STR_LIT>':<EOL><INDENT>req.write("""<STR_LIT>""" % {<EOL>'<STR_LIT:url>': escape(req.unparsed_uri, True),<EOL>'<STR_LIT>': escape(req.unparsed_uri)<EOL>})<EOL><DEDENT>raise apache.SERVER_RETURN(apache.DONE)<EOL><DEDENT>req.headers_out["<STR_LIT>"] = url<EOL>if req.response_sent_p:<EOL><INDENT>raise IOError("<STR_LIT>")<EOL><DEDENT>req.status = redirection_type<EOL>req.write('<STR_LIT>' % url)<EOL>raise apache.SERVER_RETURN(apache.DONE)<EOL>
Redirect current page to url.
@param req: request as received from apache
@param url: url to redirect to
@param redirection_type: what kind of redirection is required:
e.g.: apache.HTTP_MULTIPLE_CHOICES             = 300
      apache.HTTP_MOVED_PERMANENTLY            = 301
      apache.HTTP_MOVED_TEMPORARILY            = 302
      apache.HTTP_SEE_OTHER                    = 303
      apache.HTTP_NOT_MODIFIED                 = 304
      apache.HTTP_USE_PROXY                    = 305
      apache.HTTP_TEMPORARY_REDIRECT           = 307
The default is apache.HTTP_MOVED_TEMPORARILY
@param norobot: wether to instruct crawlers and robots such as GoogleBot
    not to index past this point.
@see: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3