My only complaint with it is this half-way json vs standard config file situation in which it finds itself. The documents push you to the json system, but most of the available documents are in the config system.
There's also some handy features that are only available in the JSON format. e.g. `strip_path_suffix` and `http_redirect` for the `rewrite` handler (https://github.com/caddyserver/caddy/issues/2011#issuecommen...), which would be a more ergonomic way to set a rule to strip trailing slashes than handling via regex.
While it is true that some features are only possible via JSON config, the ones you mentioned are available in the Caddyfile. See the uri directive which lets you strip a suffix, and redir which performs Location redirects. Also, the issue you linked to is from an early beta of Caddy v2, and the discussion and config there no longer applies.
It can also do regex replacements on the path portion of the URI. And yes, these are internal rewrites since uri is a directive that wires up the rewrite handler.
Note that the file_server will automatically enforce canonical URIs, including redirecting to add or remove the trailing slash according to whether the resource is a file or a directory.
To redirect many unspecified paths, your regex is probably the best way to do it for now. Feel free to open an issue to propose an alternative!
Thanks! I'd read all that documentation and came to the same conclusion. I'm using disable_canonical_uris as I prefer avoiding trailing slashes even for directories (as I see it, page_name/index.html layout is an implementation detail, and I'd like Caddy to expose it as /page_name).
I'll follow up with issues tomorrow (I think an issue for updating the common caddyfile patterns bit on the website also makes sense - I suspect a blanket rule for removing trailing slashes is more likely to be a common pattern people seek a solution for than removing a trailing slash on explicitly enumerated paths).
The problem is, in the browser, relative URLs (like on CSS/JS assets and such) won't be relative to your index.html if you remove the trailing slash, and they'll instead be relative to the parent directory. That can mess things up.
Of course if you're using absolute paths in your HTML then this isn't a problem, but it does become a problem if you want to move to serving this same site from a subpath, because then your absolute paths won't be constrained to this subpath.
JSON is the "machine readable" config language for Caddy, but a great majority of users are using the Caddyfile. What are you confused about specifically?