Does {uri} equals {path}?{query}?

1. The problem I’m having:

I can not submit code , so I use img, because:

the problem:
I convert ngnix config to caddy ,my nginx config:


my caddyFile :

but when it does not work, the jscode params not append to the query, when I change:

it worked, I don’t know why?

2. Error messages and/or full log output:

like 1

3. Caddy version:

v2.5.2 h1:eCJdLyEyAGzuQTa5Mh3gETnYWDClo1LjtQm2q9RNZrs=

4. How I installed and ran Caddy:

a. System environment:


b. Command:

caddy start

c. Service/unit/compose file:


d. My complete Caddy config:


5. Links to relevant resources:


You just want to add a jscode param to the query?

rewrite * ?{query}&jscode=asdf

{uri}&… Won’t work right if there is no query string in the URI.

1 Like

thanks, I test some case:

  • if exist ?, before ? can rewrite path, after ? can rewrite query, if before ? is empty, then path will not change, but if after ? is empty, then rewrite query to empty. example :

    rewrite rule:  ?cd=2 
    get : (path not change, only change query)
    rewrite rule:  ? 
    get : (path not change, query is empty)
    rewrite rule:  /mn?cd=2 
    get : (path and query change)
  • if not exist ?, default is rewrite path, and query will not change, example :

    rewrite rule:  /mn
    get : (path change, query not change)
  • if use {path} or {query}, and append some params before or after their, it worked , but if use {uri}, only before {url} part can work , after {url} part will ignore, so my &jscode=asdf is not work. example :

    rewrite rule:  /mn{path}/op
    get : (path before and after change)
    rewrite rule:  ?mn/{query}/op
    get : (query before and after change)
    rewrite rule:  mn/{uri}/op
    get : (uri only before part change)