diff --git a/pkg/gpaccount/servehttp.go b/pkg/gpaccount/servehttp.go index 09b7419..140e0a7 100644 --- a/pkg/gpaccount/servehttp.go +++ b/pkg/gpaccount/servehttp.go @@ -7,6 +7,7 @@ import ( "strconv" "github.com/Ennovar/gPanel/pkg/routing" + "strings" ) // ServeHTTP function routes all requests for the private webhost server. It is used in the main @@ -19,6 +20,12 @@ func (con *Controller) ServeHTTP(res http.ResponseWriter, req *http.Request) { path = (con.DocumentRoot + path) } + if strings.HasSuffix(path, "index.html") { + if con.checkAuth(res, req) == true { + http.Redirect(res, req, "gPanel.html", http.StatusFound) + } + } + if reqAuth(path) { if !con.checkAuth(res, req) { con.AccountLogger.Println(path + "::" + strconv.Itoa(http.StatusUnauthorized) + "::" + http.StatusText(http.StatusUnauthorized)) diff --git a/pkg/gpserver/servehttp.go b/pkg/gpserver/servehttp.go index b6580b8..a4a778a 100644 --- a/pkg/gpserver/servehttp.go +++ b/pkg/gpserver/servehttp.go @@ -7,6 +7,7 @@ import ( "strconv" "github.com/Ennovar/gPanel/pkg/routing" + "strings" ) func (con *Controller) ServeHTTP(res http.ResponseWriter, req *http.Request) { @@ -17,6 +18,12 @@ func (con *Controller) ServeHTTP(res http.ResponseWriter, req *http.Request) { path = (con.Directory + con.DocumentRoot + path) } + if strings.HasSuffix(path, "index.html") { + if con.checkAuth(res, req) == true { + http.Redirect(res, req, "gPanel.html", http.StatusFound) + } + } + if reqAuth(path) { if !con.checkAuth(res, req) { con.ServerLogger.Println(path + "::" + strconv.Itoa(http.StatusUnauthorized) + "::" + http.StatusText(http.StatusUnauthorized))