mirror of
https://github.com/caddyserver/caddy.git
synced 2025-04-23 21:24:06 +08:00
simplify
This commit is contained in:
parent
06a945d49d
commit
d85c778775
@ -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{
|
||||
|
Loading…
x
Reference in New Issue
Block a user