How to check for an empty (or absence of) Query Parameter

1. Caddy version:

2.6.2

simple question.

  1. If someone goes to my url, app.server1.c0m,
    I need to append “/main” to the url when I reverse proxy to my server only if they had nothing after “.com”

I’m using this now:

app.server1.c0m {
reverse_proxy * {
to http://209.10.59.102
}
}

So i’d need this to end up going to: http://209.10.59.102/app

  1. If there IS a Query Parameter, I need to only allow it to go to the server IF it begins with “app”.

So if the request is: app.server1.c0m/index.html I would DISALLOW this. With some status code.
If the request is: app.server1.c0m/app/index.html , then its fine. send it on unmodified.

Is this possible?

I searched docs and tried things for over 1 hour and I see instructions for forwarding or redir to /b if they typed /a.
but i also need to check for null or empty string. i could not find example of this.

redir / /main

That’s not a query, that’s a path. The query part of the URL is the part starting with ? like for example ?foo=bar.

The path is the part after the domain, i.e. /foo/bar.

To handle only requests with a path beginning with /app, make a handle which matches that path, then another handle which catches anything else:

handle /app* {
	# do whatever
}

handle {
	respond "Nope" 404
}

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