Different roots for different paths

Hi,
I’m having an issue serving my website switching root based on path

I have a main website that has

https://mysite.tld {
        #website
        root /var/www/mysite/public
        hugo /var/www/mysite
}

now I want to serve a security.txt file on https://mysite/.well-known/security.txt

so i tried adding the following to my caddyfile:

https://mysite.tld/.well-known {
      root /var/www/.well-known
}

Caddy works but visiting the path it shows the 404 of hugo, so I’m assuming it still consider it under the same root

Hi @frame,

This isn’t the case - the root directive is handled completely separately for each site definition.

If I received a Hugo 404 for a site definition that has no hugo directive, I would first look into making sure the updated Caddyfile is properly loaded, and that the site label in the Caddyfile matches the Host and URI requested. Caddy selects the appropriate site definition based on the longest matching site label.

Hi @Whitestrake you were indeed right, was just a cache issue. Thanks for the help :slight_smile:

1 Like

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