【问题标题】:In web.py, How to 301 redirect to another domain?在 web.py 中,如何 301 重定向到另一个域?
【发布时间】:2013-10-22 00:34:15
【问题描述】:

web.py 中的函数 seeother() 和 redirect() 没有用。我尝试使用
web.header('Location', 'www.google.com')
web.header('status', '301')

web.HTTPError('301', {'Location': 'www.google.com'})
但仍重定向到:
http://127.0.0.1:80/www.google.com
这不是我们想要的:
http://google.com
如何正确重定向?

【问题讨论】:

    标签: python http web web.py


    【解决方案1】:

    用途:

    web.HTTPError('301', {'Location': 'http://www.google.com'})
    

    请注意,您必须输入 http:// 来表示绝对 URL。

    【讨论】:

      【解决方案2】:

      这不是我们想要的: http://google.com

      那你为什么要重定向到www.google.com而不是http://google.com

      【讨论】:

        猜你喜欢
        • 2013-05-18
        • 2017-06-15
        • 2016-07-30
        • 2011-03-04
        • 2015-12-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-09-02
        相关资源
        最近更新 更多