1. The problem I’m having:
I have looked into existing related topics and the closest i found was Do not require .html extension Caddy v2
But i still cannot make it work.
I have the following apps/http/servers config:
{
"website": {
"listen": [":443"],
"routes": [
{
"match": [
{
"host": ["example.com"]
},
{
"file": {
"root": "/var/www/quartz/public",
"try_files": [
"{http.request.uri.path}",
"{http.request.uri.path}.html"
]
}
}
],
"handle": [
{
"handler": "encode",
"encodings": {
"gzip": {},
"zstd": {}
}
},
{
"handler": "rewrite",
"uri": "{http.matchers.file.relative}{http.request.uri.query_string}"
}
{
"handler": "file_server",
"root": "/var/www/quartz/public",
"hide": [".git"]
}
]
}
]
}
}
what i am trying to do is to map any request without .html
extension to look for a file with that extension and rewrite to it.
my understanding is that {http.matchers.file.relative}
should contain a value if the file matcher matched, but it seems to stay empty. so i conclude the file matcher does not match. is there a way to debug the actual filepath it tries with try_files
?
or anything else i am missing?
2. Error messages and/or full log output:
current output: since the rewrite becomes an empty string it rewrite all the quest to empty string so basically looking for the index.html
. so all request return the content of the index.html
.
my understanding is that the file matcher would not match if non of the try_files match resulting in a not-found.
3. Caddy version:
v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=
4. How I installed and ran Caddy:
a. System environment:
installed on a debian using apt.
b. Command:
runs with systemd that gets installed with apt.
c. Service/unit/compose file:
na
d. My complete Caddy config:
see above