【问题标题】:Automatically 301 Redirecting in GoGo 中自动 301 重定向
【发布时间】:2011-12-20 00:51:33
【问题描述】:

我正在尝试将 url 重定向到不同的 url(301 或 301)。基本上,我正在寻找与以下 php 代码等效的 go:

<?php
// Permanent redirection
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://google.com/");
?>

到目前为止,这是我所做的:

writer.Header().Set("Location", "http://google.com")
writer.WriteHeader(301)

还有:

handler := rawHttp.RedirectHandler("http://google.com", 301)
handler.ServeHTTP(writer, req)

它“有点”有效。唯一的问题是它写了一个带有http://google.com 链接的“找到”文本,所以我必须点击它。我希望它自动重定向而不显示“找到”链接。

【问题讨论】:

    标签: redirect go


    【解决方案1】:

    解决了。要么工作。我只是在设置重定向之前发送了一些文本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-09
      • 1970-01-01
      • 2015-04-07
      • 1970-01-01
      • 1970-01-01
      • 2013-11-17
      • 1970-01-01
      相关资源
      最近更新 更多