1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-08 20:41:57 +00:00

support multi-level subdomains redirect, see previous commit for the SubdomainRedirect fast solution

Former-commit-id: bc5749e46d1ae65f9d17063f3d8f2ea72510a9d8
This commit is contained in:
Gerasimos (Makis) Maropoulos
2018-01-20 14:54:04 +02:00
parent e176ff7b0c
commit 25918427bc
5 changed files with 12 additions and 5 deletions

View File

@@ -10,7 +10,6 @@ It doesn't always contain the "best ways" but it does cover each important featu
- [Hello world!](hello-world/main.go)
- [Glimpse](overview/main.go)
- [WWW](www/main.go)
- [Tutorial: Online Visitors](tutorial/online-visitors/main.go)
- [Tutorial: A Todo MVC Application using Iris and Vue.js](https://hackernoon.com/a-todo-mvc-application-using-iris-and-vue-js-5019ff870064)
- [Tutorial: URL Shortener using BoltDB](https://medium.com/@kataras/a-url-shortener-service-using-go-iris-and-bolt-4182f0b00ae7)

View File

@@ -1,4 +1,4 @@
127.0.0.1 mydomain.com
127.0.0.1 www.mydomain.com
127.0.0.1 mydomain.com
127.0.0.1 www.mydomain.com
# Windows: Drive:/Windows/system32/drivers/etc/hosts, on Linux: /etc/hosts

View File

@@ -44,6 +44,11 @@ func newApp() *iris.Application {
// First argument is the 'from' and second is the 'to/target'.
app.SubdomainRedirect(app, www)
// SubdomainRedirect works for multi-level subdomains as well:
// subsub := www.Subdomain("subsub") // subsub.www.mydomain.com
// subsub.Get("/", func(ctx iris.Context) { ctx.Writef("subdomain is: " + ctx.Subdomain()) })
// app.SubdomainRedirect(subsub, www)
//
// If you need to redirect any subdomain to 'www' then:
// app.SubdomainRedirect(app.WildcardSubdomain(), www)
// If you need to redirect from a subdomain to the root domain then: