How to block certain file type and directory access in Caddy v2?
In caddy v1 we had
rewrite {
if_op or
if {file} ends_with .txt
if {file} ends_with .md
if {file} ends_with .mdown
if {uri} starts_with /dir1/
if {uri} starts_with /dir2/
to /index.php
}
You can choose whether to rewrite or redir or respond to block those requests, it depends on your usecase which fits best for you. I just used respond above as an example.
Many thanks Francis, indeed much simpler in v2. As you can tell I’m upgrading some old Kirby 2 CMS sites for Caddy v2, I’ll document it on this community when I’ve done and people can then check to make sure I’ve done it in the best way.