How to redirect all URLs to a single handler?

41 views
Skip to first unread message

so.q...@gmail.com

unread,
Mar 9, 2017, 1:36:57 AM3/9/17
to google-appengine-go
What would I need to put in my app.yaml and main.go, to make sure any URL directed to my domain redirects to home? So it avoids 404 errors.

The following URLs would all be handled by the same page: www.foo.com, foo.com, bar.foo.com, www.foo.com/bar, foo.com/baz

It is possible to use ServeMux?
https://golang.org/pkg/net/http/#ServeMux


Chris Broadfoot

unread,
Mar 9, 2017, 2:29:26 AM3/9/17
to so.q...@gmail.com, google-appengine-go
http.HandleFunc("/", handler)

"/" will match any path.

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine-go+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

st ov

unread,
Mar 9, 2017, 12:06:26 PM3/9/17
to google-appengine-go, so.q...@gmail.com
I'm not seeing that behavior when using "/", but instead "This site can't be reached".
What should be in the app.yaml?
Reply all
Reply to author
Forward
0 new messages