0

I have the following html/ directory and a Caddyfile:

Caddyfile
html/
├── 404.html
├── 500.html
├── about.html
├── blog
│   ├── one.html
│   ├── two.html
│   └── three.html
├── blog.html
├── home.html
├── projects.html
└── static
    ├── css
    │   └── site.css
    ├── images
    │   ├── favicon.ico
    └── js
        └── highlight.pack.js

I'd like requests to resolve in the following way:

  • localhost:8080/ or localhost:8080 -> serves html/home.html
  • localhost:8080/about -> serves html/about.html
  • localhost:8080/about/ -> serves html/about.html -> rewrites URI to /about
  • localhost:8080/about.html -> serves html/about.html -> rewrites URI to /about
  • localhost:8080/blog/one -> serves `html/blog/one.html
  • 404 and 500 errors serve html/404.html and html/500.html respectively

I feel like I have it almost right but the combination of uri and try_files is not producing the exact effect as described above:

http://localhost:8080

uri strip_suffix .html
try_files {path}.html

handle_errors {
    rewrite * html/{err.status_code}.html
    file_server
}

file_server {
    index home.html
    root html
}

Do the requests for .html extension URIs have to be redirected somehow to their non-.html equivalents?

mart1n
  • 5,969
  • 5
  • 46
  • 83

0 Answers0