How to scape question sign in URL?

1. The problem I’m having:

I’m using path_regexp:

uri path_regexp ^/index/([^/]+)/([^/]+)$ /index.php?codigo=$1&cidade=$2

Using the Debug, I see it don’t works because it doesn’t keep the question sign (?) after the name page. The debug shows me that the generated uri is:


See above that it puts “%3F” at question sign place. I already tried two slashes (\\) before question sign, but it doesn’t work too. I need the result of my regex be:


How do I do it?

2. Error messages and/or full log output:

It goes to index.html page, because it doesn’t find the wrong path generated by regex above

3. Caddy version:

v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=

4. How I installed and ran Caddy:

binary file

a. System environment:

Debian Linux 11.0

b. Command:

caddy run --config Caddyfile

The URL I’m calling:

d. My complete Caddy config:

:9191 {
        root * /home/paulo/projeto_php


        uri path_regexp ^/index/([^/]+)/([^/]+)$ /index.php?codigo=$1&cidade=$2

        try_files {path} index.html index.htm

Use a path_regexp matcher + the rewrite directive, not the uri directive with the path_regexp mode. The path_regexp mode specifically only operates on the path, not the full URI.