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:
@@ -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
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user