Grav Feed Problem

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.

Thanks a lot,

Benny

Hmm, Grav looks cool!

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?

It’s the stock grav Caddyfile :smiley: Does it have to be in the root folder of grav?

Tried it with this one → grav/Caddyfile at af53d79e5ee5f9cdc407b799a204c79897bf21d7 · getgrav/grav · GitHub does’nt work either.

Here is the newest Caddyfile which is used for the whole Domain, including subdomain. examples/Caddyfile at master · caddyserver/examples · GitHub

Aha! I found the problem, it was a bit sneaky.

The issue was this block:

    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.

See: working posts collection, working posts rss feed, and my Caddyfile.

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…

2 Likes

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 :slight_smile:

Excellent. Could I ask what changes your friend made?

I did only see your first post, which as you predicted didn’t work.
So we both figured it out separately but came to the same conclusion. :smiley:

I also added the update to the caddy examples :slight_smile:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.