Different roots for different paths


(z) #1

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 onhttps://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


(Matthew Fay) #2

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.


(z) #3

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