fastcgi: Preserve query during canonical redirect

This commit is contained in:
Francis Lavoie 2024-11-27 22:33:48 -05:00
parent 533a77c3fd
commit b47b2149ac
No known key found for this signature in database
GPG Key ID: 52BC55A211F19186
6 changed files with 7 additions and 7 deletions

View File

@ -8,7 +8,7 @@ route {
} }
not path */ not path */
} }
redir @canonicalPath {http.request.orig_uri.path}/ 308 redir @canonicalPath {http.request.orig_uri.path}/{http.request.uri.prefixed_query} 308
# If the requested file does not exist, try index files # If the requested file does not exist, try index files
@indexFiles { @indexFiles {
@ -50,7 +50,7 @@ route {
"handler": "static_response", "handler": "static_response",
"headers": { "headers": {
"Location": [ "Location": [
"{http.request.orig_uri.path}/" "{http.request.orig_uri.path}/{http.request.uri.prefixed_query}"
] ]
}, },
"status_code": 308 "status_code": 308

View File

@ -42,7 +42,7 @@
"handler": "static_response", "handler": "static_response",
"headers": { "headers": {
"Location": [ "Location": [
"{http.request.orig_uri.path}/" "{http.request.orig_uri.path}/{http.request.uri.prefixed_query}"
] ]
}, },
"status_code": 308 "status_code": 308

View File

@ -33,7 +33,7 @@ php_fastcgi @test localhost:9000
"handler": "static_response", "handler": "static_response",
"headers": { "headers": {
"Location": [ "Location": [
"{http.request.orig_uri.path}/" "{http.request.orig_uri.path}/{http.request.uri.prefixed_query}"
] ]
}, },
"status_code": 308 "status_code": 308

View File

@ -43,7 +43,7 @@ php_fastcgi localhost:9000 {
"handler": "static_response", "handler": "static_response",
"headers": { "headers": {
"Location": [ "Location": [
"{http.request.orig_uri.path}/" "{http.request.orig_uri.path}/{http.request.uri.prefixed_query}"
] ]
}, },
"status_code": 308 "status_code": 308

View File

@ -46,7 +46,7 @@ php_fastcgi localhost:9000 {
"handler": "static_response", "handler": "static_response",
"headers": { "headers": {
"Location": [ "Location": [
"{http.request.orig_uri.path}/" "{http.request.orig_uri.path}/{http.request.uri.prefixed_query}"
] ]
}, },
"status_code": 308 "status_code": 308

View File

@ -343,7 +343,7 @@ func parsePHPFastCGI(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error
} }
redirHandler := caddyhttp.StaticResponse{ redirHandler := caddyhttp.StaticResponse{
StatusCode: caddyhttp.WeakString(strconv.Itoa(http.StatusPermanentRedirect)), StatusCode: caddyhttp.WeakString(strconv.Itoa(http.StatusPermanentRedirect)),
Headers: http.Header{"Location": []string{"{http.request.orig_uri.path}/"}}, Headers: http.Header{"Location": []string{"{http.request.orig_uri.path}/{http.request.uri.prefixed_query}"}},
} }
redirRoute := caddyhttp.Route{ redirRoute := caddyhttp.Route{
MatcherSetsRaw: []caddy.ModuleMap{redirMatcherSet}, MatcherSetsRaw: []caddy.ModuleMap{redirMatcherSet},