This commit is contained in:
Kévin Dunglas 2024-11-19 00:08:14 +01:00
parent 06a945d49d
commit d85c778775
No known key found for this signature in database
GPG Key ID: 4D04EBEF06AAF3A6

View File

@ -310,25 +310,24 @@ func parsePHPFastCGI(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error
// if the index is turned off, we skip the redirect and try_files
if indexFile != "off" {
var disableDirRedir bool
dirRedir := false
dirIndex := "{http.request.uri.path}/" + indexFile
// if tryFiles wasn't overridden, use a reasonable default
if len(tryFiles) == 0 {
tryFiles = []string{"{http.request.uri.path}", "{http.request.uri.path}/" + indexFile, indexFile}
tryFiles = []string{"{http.request.uri.path}", dirIndex, indexFile}
dirRedir = true
} else {
indexPattern := "{http.request.uri.path}/" + indexFile
disableDirRedir = true
for _, tf := range tryFiles {
if tf == indexPattern {
disableDirRedir = false
if tf == dirIndex {
dirRedir = true
break
}
}
}
if !disableDirRedir {
if dirRedir {
// route to redirect to canonical path if index PHP file
redirMatcherSet := caddy.ModuleMap{
"file": h.JSON(fileserver.MatchFile{