When a user accesses my site, example.com, I want the path bar to be hidden in the browser. Now the URL in the browser would automatically change to example.com/bar. How should I change my CaddyFile?
A rewrite does not expose the path changes and its effects are only internal. Can you please add:
{
debug
}
at the top of your Caddyfile, collect some logs, and share them? Logs are actually one of the requirements in the template, but that section appears to be removed in your submission.
Matching on / only matches requests to exactly / and nothing else. To match all paths, you must use *. Then, to preserve the path and query from the request when rewriting, you should use the {uri} placeholder.
rewrite * /bar{uri}
This would be triggered by your upstream application (the thing you’re proxying to). It’s responding to requests, instructing the browser to redirect. This is done via the Location: header in the responses.
That said, please properly and completely fill out the help topic template when asking questions on these forums. It’ll save time for both you and us, by avoiding some needless back and forth.