Force no file extension

1. Output of caddy version:


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:


root * projects/test/dist

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

encode zstd gzip

error /index* 404
error /error* 404

handle_errors {
	rewrite error.html


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.