Rewrite file not found & migrate problems

1. Caddy version (caddy version):


2. How I run Caddy:

a. System environment:


b. Command:

Once I’ve done

caddy start

And now I use this for update config

caddy adapt --config /etc/caddy/Caddyfile > caddy.json
curl localhost:2019/load -X POST -H "Content-Type: application/json" -d @caddy.json

d. My complete Caddyfile or JSON config: {
    root * /var/www/
    # Enable the static file server.

    php_fastcgi unix//run/php/php7.0-fpm.sock

    @webhook path_regexp ^/webhook/([0-9a-zA-Z_]+)$
    rewrite @webhook /folder/{re.webhook.1}/script.php?{path}

3. The problem I’m having:

Navigate to returns 404 and “File not found.”
Expected open like

4. Error messages and/or full log output:

I don’t know how to enable debug logs

5. What I already tried:

I set

log {
        level DEBUG
        output file /data/log/caddy_test.log {
           roll_size 10MiB
           roll_keep 10
           roll_keep_for 336h

but i don’t see debug logs about this error.

All I want to do, migrate

rewrite /webhook {
 	r  ^/(\w+)/?$
 	to /folder/{1}/script.php?{query}

to new version

Thanks for any help

I’ll figured out

@webhook {
path_regexp webhook ^/webhook/([0-9a-zA-Z_]+)$

Add this at the top of your Caddyfile:


I think you probably wanted {query} rather than {path} as per your v1 example.

You can shorten this slightly by making it a one liner:

@webhook path_regexp webhook ^/webhook/([0-9a-zA-Z_]+)$

Glad you figured it out!

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