The Permanent Redirect HTTP header

A 301 Permanent Redirect with a Location header will automatically be followed by browsers. Example Go code follows:

package main

import (

var interruptChannel = make(chan os.Signal, 1)

func redirect(w http.ResponseWriter, req *http.Request) {
	w.Header().Set("Location", "")

func main() {
	http.HandleFunc("/redirect", redirect)
	server := http.Server{Addr: ":8080"}
	http.ListenAndServe(":8080", nil)
	go server.ListenAndServe()
	log.Println("Shutting down server")
	server.Shutdown(context.Background()) // blocks until all active connections become idle