mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-21 00:41:59 +08:00
Changes regarding comment.
Used http status code instead of a hardcoded value. Used url.Parse instead of url.ParseRequestURI, so that you can parse both absolute and relative URL.
This commit is contained in:
parent
8a2d0890a2
commit
eea68c34ad
|
@ -23,9 +23,9 @@ func (rd Redirect) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error
|
|||
for _, rule := range rd.Rules {
|
||||
if rule.From == "/" {
|
||||
// Catchall redirect preserves path (TODO: Standardize/formalize this behavior)
|
||||
toURL, err := url.ParseRequestURI(rule.To)
|
||||
toURL, err := url.Parse(rule.To)
|
||||
if err != nil {
|
||||
return 500, err
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
newPath := toURL.Host + toURL.Path + r.URL.Path
|
||||
rmSlashs := regexp.MustCompile("//+")
|
||||
|
|
Loading…
Reference in New Issue
Block a user