Force no file extension

1. Output of caddy version:

v2.6.1

2. How I run Caddy:

a. System environment:

Arch Linux, Systemd

b. Command:

`caddy start`

c. Service/unit/compose file:

d. My complete Caddy config:

localhost

root * projects/test/dist

rewrite /*.html /error.html
try_files {path}.html

encode zstd gzip
templates

error /index* 404
error /error* 404

handle_errors {
	rewrite error.html
	templates
	file_server
}

file_server

3. The problem I’m having:

I want to completely erase the .html file extension, try_files rule makes html files accessible without .html, but doesn’t prevent the default behaivor.

rewrite rule works, but only before the second / in the path, e.g.:

/page 200
/page.html 404
/folder/page 200
/folder/page.html 200 (should also be 404)

4. Error messages and/or full log output:

5. What I already tried:

error rewrite

6. Links to relevant resources:

This topic was automatically closed after 30 days. New replies are no longer allowed.