【发布时间】: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 链接的“找到”文本,所以我必须点击它。我希望它自动重定向而不显示“找到”链接。
【问题讨论】: