However this also does a redirect for the files that exist - therefore causing a redirect loop.
The apache config emits a 301 redirect to the new file.
Given we could in theory test for the actual file to exist or not (the !-f in the apache rule) and only issue a redir if the file doesn’t exist.
I haven’t managed to figure out how to meet these conditions though - essentially it would be a combination of path_regexp and either files or try_files maybe?
I just can’t seem to figure out a syntax that works.
EDIT: I did get the following to be almost there, but I can’t browse the directory listings anymore…
@ersa {
path_regexp ^/xplane/charts/ERSA.+/(.*)$
not file
}
redir @ersa /xplane/charts/ERSA-2024-MAR-21/{re.1}
@daps {
path_regexp ^/xplane/charts/DAPS.+/(.*)$
not file
}
redir @daps /xplane/charts/DAPS-2024-MAR-21/{re.1}
ie if a directory was browsed like: /xplane/charts/DAPS-2023-JAN-01/ is visited, it should also be rewritten to /xplane/charts/DAPS-2024-MAR-21/
Ok, after quite a while of trial and error, I think I’ve got a properly working config for this…
handle /xplane/charts/* {
vars {
cycle "2024-MAR-21"
}
@daps {
not file
not path /xplane/charts/DAPS-{vars.cycle}/
path_regexp ^/xplane/charts/DAPS.+/(.*)$
}
@ersa {
not file
not path /xplane/charts/ERSA-{vars.cycle}/
path_regexp ^/xplane/charts/ERSA.+/(.*)$
}
redir @daps /xplane/charts/DAPS-{vars.cycle}/{re.1} permanent
redir @ersa /xplane/charts/ERSA-{vars.cycle}/{re.1} permanent
file_server {
browse
}
}
However, it doesn’t seem like the {vars.cycle} seems to match in the not path directives, which leads to a redirect loop when trying to browse the directory.
If I replace {vars.cycle} with 2024-MAR-21 in the not path lines, then it seems to work properly.
Are there limitations in the path match for using variables or is this a bug?