How can fix Simple Problem in redirect?

H. Sorry. Me reading a bit too fast. You could do like this Run multi web servers on one pysical server or vps to have to different servermux’s or use the default for https and just a new one for http with only one redirect method.

package main

import (
	"io"
	"net/http"
)

func index1(w http.ResponseWriter, r *http.Request) {
	io.WriteString(w, "Hello from server 1")
}

func index2(w http.ResponseWriter, r *http.Request) {
	io.WriteString(w, "Hello from server 2")
}

func main() {

	mux := http.NewServeMux()
	mux.HandleFunc("/", index1)

	http.HandleFunc("/", index2)

	go http.ListenAndServe("localhost:8001", mux)

	http.ListenAndServe("localhost:8002", nil)
}
1 Like