CherryPy可以将HTTP重定向到HTTPS。举例来说,如果有人通过https://example.com访问我想让他们被重定向到普通的HTTP URL(301重定向也许?使用CherryPy将HTTPS转换为HTTP
#!/usr/bin/env python
from pprint import pformat
from cherrypy import wsgiserver
def app(environ, start_response):
status = '200 OK'
response_headers = [('Content-type', 'text/plain')]
start_response(status, response_headers)
return [pformat(environ)]
server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 80), app)
try:
server.start()
except KeyboardInterrupt:
server.stop()
为什么在CherryPy的做到这一点时,Apache可以更有效地做到这一点? –