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:

image

my caddyFile :
image

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

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:

win10

b. Command:

caddy start

c. Service/unit/compose file:

none

d. My complete Caddy config:

none

5. Links to relevant resources:

none

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 http://example.com/abc/?def=3 :

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

    rewrite rule:  /mn
    get : http://example.com/mn/?def=3 (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 http://example.com/abc/?def=3 :

    rewrite rule:  /mn{path}/op
    get : http://example.com/mn/abc/op?def=3 (path before and after change)
    
    rewrite rule:  ?mn/{query}/op
    get : http://example.com/abc/?mn/def=3/op (query before and after change)
    
    rewrite rule:  mn/{uri}/op
    get : http://example.com/mn/abc/?def=3 (uri only before part change)
    

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