diff --git a/README.md b/README.md index 7be6cb0..ac7cd49 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,17 @@ ## 应用场景 ## 1. 做301跳转 -2. 短域名,比如:to2.net/blog 跳转到我的博客http://www.s1n1.com +2. 短域名,比如:to2.net/git 跳转到 http://github.com/jsix ## 配置 ## -配置文件后缀为*.conf,启动时会加载改目录下的所有配置。 默认加载根目录下的配置。 +配置文件为: *.conf,启动时会加载目录(默认为当前目录,可以通过dir参数指定)下的所有配置。 + host项支持通配,如: *.to2.net 能匹配 to2.net的所有子域名 ## 启动 ## -./gord -dir=./ -port=8032 + ./gord + 第一次运行会生成一个默认的配置示例: [ @@ -20,11 +22,12 @@ host项支持通配,如: *.to2.net 能匹配 to2.net的所有子域名 "to": "http://www.to2.net/{path}{query}", "location": { "/1/2/3/": "http://a.com/{#0}-{#1}-{#2}", - "/a": "http://a.com", - "/a/b": "http://a.com/{path}{query}", - "/b/*": "http://b.com/{*}" + "/a": "http://a.com/{path}{query}", + "/b/*": "http://b.com/t-{*}" } } ] + + diff --git a/example.conf b/example.conf index f84b378..963231d 100644 --- a/example.conf +++ b/example.conf @@ -4,8 +4,7 @@ "to": "http://www.to2.net/{path}{query}", "location": { "/1/2/3/": "http://a.com/{#0}-{#1}-{#2}", - "/a": "http://a.com", - "/a/b": "http://a.com/{path}{query}", + "/a": "http://a.com/{path}{query}", "/b/*": "http://b.com/t-{*}" } } diff --git a/gord.go b/gord.go index 041d737..1145f06 100644 --- a/gord.go +++ b/gord.go @@ -108,9 +108,8 @@ func (i *ItemManager) initExample() { Host: "*.to2.net", To: "http://www.to2.net/{path}{query}", Location: map[string]string{ - "/a": "http://a.com", + "/a": "http://a.com/{path}{query}", "/b/*": "http://b.com/t-{*}", - "/a/b": "http://a.com/{path}{query}", "/1/2/3/": "http://a.com/{#0}-{#1}-{#2}", }, }, @@ -219,7 +218,7 @@ type redirectHandler struct { func (r *redirectHandler) ServeHTTP(rsp http.ResponseWriter, req *http.Request) { host := req.Host - // host = "www.to2.net" // "z3q.net" use for test + // host = "www.to2.net" // "to2.net" use for test var item *Item = r.itemManager.GetItemByHost(host) if item != nil { if location, b := r.getLocation(rsp, req, item); b {