I successfully redirect www to non-www. Now I’m trying to redirect path to a subdomain, e.g.: abc.com/blog/something123 to blog.abc.com/something123
With above Caddyfile I get the following error and the redirect still not work.
4. Error messages and/or full log output:
WARN caddyfile Using a path in a site address is deprecated; please use the 'handle' directive instead {"address": "http://abc.com/blog"}
As the warning you got in your logs say, path matchers in the site address is deprecated, so you must put your path matcher within the site, applied to some directive.
What you tried with handle does not work because handle is a directive, it must go within a site block. Caddy will be parsing this as if handle is one of your domain names you’re trying to serve, but that doesn’t make sense. See the docs for the Caddyfile config structure:
Finally, I strongly suggest moving your site’s files to /var/www/html or /srv instead of having it in /home. You can run into permission issues by having it in /home if the user Caddy runs as can’t read those files.
The handle_path directive will strip the matched path segment before handling things within.
Keep in mind that requests that aren’t to /blog* will result in an empty response. You should probably configure something else to run for other paths.