Hey, i set up a blog with caddy and grav. Grav provides (with or without a specific plugin) a rss feed. Now i have the problem that with caddy i get a 404 error. I tested the whole site with apache (copied the whole grav directory) and there it is working just fine. Maybe someone has a suggestíon on how to fix this.
My first thought is that you might be missing rewrite rules. Grav comes with a .htaccess file so Apache would pick up on these out of the box. I can see that their git has some example webserver configs including a Caddyfile, how does your own Caddyfile compare?
rewrite {
regexp .*
ext /
to /index.php?_url={uri}
}
First, why is there a regex check? Just rewrite / for a catch-all. Second, note ext /, which effectively means it is ONLY rewriting when there is NO file extension. So because Caddy has a root /path/to/site, and /collection.rss is NOT being rewritten (because it has a file extension), Caddy is looking for the file in the webroot and not finding it (hence 404).
I have rewritten this block like so:
rewrite / {
to {path} {path}/ /index.php?_url={uri}
}
I’m not sure what other ramifications this will have as the person who wrote the Caddyfile in the first place may have had good reason not to rewrite files with extensions. It may very well break media, I’m not sure. But my RSS feed works, so. For some reason, it does not work with a simple rewrite / /index.php?_url={uri} one-liner.
Edit: Updated block again to include to {path} {path}/ /index.php?_url={uri}, which should counter my concerns about possibly breaking things by rewriting literally everything to index.php…
Thank you, this was the solution. My mate Niklas had to modify it a bit because there was a problem with the pictures but now everything is working perfect