1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-09 21:15:56 +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

@@ -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: