Changing file server directory through matchers

Hello,
I am new to caddy but this used to work for me in the past and now somehow i am not able even if the matcher is correct it is not showing the index.html of that route + matcher

{
        security {
                authorization policy validation {
                        allow roles user
                        crypto key token name auth_token
                        crypto key verify test
                        set auth url https://domain.com/temp/notfound
                        disable auth redirect query
                }
        }
}

domain.com {
        @notFound {
                path /temp/notfound
        }
        route @notFound {
                root * /var/www/html/antibot
                file_server
        }
        @checkCaptcha {
                path /temp/case*
                query id=*
        }

        route @checkCaptcha {
                root * /usr/share/caddy/
                file_server
        }
        route * {
                authorize with validation
                root * /usr/share/caddy/
                file_server
        }
}

I have tried various alternatives like direct root /tmp/case* did not work
I am new to topics so sorry if i do not tell out my problem correctly

You probably want handle, not route.

You should use the order global option to assign an order to `authorize.

I don’t understand the problem you’re having.

Please fill out the help topic template as per the forum rules.

1 Like

Thanks for the help but still i am not being able to complete this, i want to show users if they visit domain.com/tmp/case?id=12389 to show root * /usr/share/caddy/captcha for user verification and if the url is otherwise without authorization to redirect to the @notFound matcher.

I tried to use handle like u said ::

{
        security {
                authorization policy validation {
                        allow roles user
                        crypto key token name auth_token
                        crypto key verify test
                        set auth url https://domain.com/temp/notfound
                        disable auth redirect query
                }
        }
}

domain.com {
        @notFound {
                path /temp/notfound
        }
        handle @notFound {
                root * /var/www/html/antibot
                file_server
        }
        @checkCaptcha {
                path /temp/case*
                query id=*
        }

        handle @checkCaptcha {
                root * /usr/share/caddy/
                file_server
        }
        handle * {
                authorize with validation
                root * /usr/share/caddy/
                file_server
        }
}```

like this it threw an error to not use authorize and handle in the same place, so i temporary removed the authentication part and tried to visit domain.com/tmp/case?id=12389 but it showed a 404 not found even though there is files there, and when i visit just domain.com it shows the correct files / displays index.html