mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 14:13:48 +03:00
Add query_string to HTTP replacer and use it for try_files
This commit is contained in:
parent
2dc4fcc62b
commit
d242f10eda
2 changed files with 8 additions and 2 deletions
|
@ -17,9 +17,9 @@ package fileserver
|
|||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caddyserver/caddy/v2/modules/caddyhttp/rewrite"
|
||||
"github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile"
|
||||
"github.com/caddyserver/caddy/v2/modules/caddyhttp"
|
||||
"github.com/caddyserver/caddy/v2/modules/caddyhttp/rewrite"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -99,7 +99,7 @@ func parseTryFiles(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error)
|
|||
}
|
||||
|
||||
handler := rewrite.Rewrite{
|
||||
URI: "{http.matchers.file.relative}{http.request.uri.query}",
|
||||
URI: "{http.matchers.file.relative}{http.request.uri.query_string}",
|
||||
}
|
||||
|
||||
matcherSet := map[string]json.RawMessage{
|
||||
|
|
|
@ -89,6 +89,12 @@ func addHTTPVarsToReplacer(repl caddy.Replacer, req *http.Request, w http.Respon
|
|||
return dir, true
|
||||
case "http.request.uri.query":
|
||||
return req.URL.RawQuery, true
|
||||
case "http.request.uri.query_string":
|
||||
qs := req.URL.Query().Encode()
|
||||
if qs != "" {
|
||||
qs = "?" + qs
|
||||
}
|
||||
return qs, true
|
||||
}
|
||||
|
||||
// hostname labels
|
||||
|
|
Loading…
Reference in a new issue