【问题标题】:Why doesn't this redirect work?为什么这个重定向不起作用?
【发布时间】:2011-08-21 20:56:07
【问题描述】:

为什么这个重定向不起作用?

$menu = 'menu';
$item = 'item';
header('HTTP/1.1 303 See Other');
header("/{$menu}/{$item}/");

【问题讨论】:

    标签: php redirect http-headers http-redirect


    【解决方案1】:

    因为您忘记指定要发送的标头。

    重定向头需要以Location:开头。

    header("Location: /{$menu}/{$item}/");
    

    【讨论】:

      【解决方案2】:

      你需要做header("Location: /{$menu}/{$item}/");

      查看HTTP 303 Wikipedia Page的示例

      服务器响应:

      HTTP/1.1 303 See Other
      Location: @987654322@

      【讨论】:

        猜你喜欢
        • 2017-06-12
        • 1970-01-01
        • 1970-01-01
        • 2016-05-14
        • 1970-01-01
        • 2016-09-13
        • 1970-01-01
        • 2012-07-05
        • 2016-04-25
        相关资源
        最近更新 更多