Whenever a request is made from localhost:9000/ I want to redirect the user to localhost:9000/#/trade/gem/GEM . The problem I am getting is that I get infinite redirects because "/" preceeds every url. How do I make it so that the user is only redirected if they visit the exact url of localhost:9000/ ? My code is below:
var newUrl string = "/#/trade/gem/GEM"
func handleRedirect(rw http.ResponseWriter, req *http.Request) {
http.Redirect(rw, req, newUrl, http.StatusSeeOther)
}
func main() {
http.Handle("/#/trade/", fs)
http.HandleFunc("/", handleRedirect) //This is the exact url I want to redirect from
http.ListenAndServe(":9000", nil)
}
#) is not transmitted to the server. You'll have pick a different approach./and/#/trade/gem/GEMon the server; they both look like/, hence the redirect loop. The fragment is for client-side use only (i.e. JavaScript).