One Caddyfile entry for www and without it

Using the latest caddy version from the Ubuntu PPA, are the only ways to support www and non www at the same time (For the same caddyfile domain entry) mean I would have to do the following or is there another way:

METHOD 1:

example.com, www.example.com {
properties for this domain
}

METHOD 2:

www.example.com {
redir example.com
}

I am asking since I would like to avoid redirecting from www to the non www and simply serve both on the same folder with the same information.

Your first example will serve both without redirecting www.example.com to example.com. Caddy will manage separate certificates for the two domains.

1 Like

Thank you Francis, so it is how I understood it. What about saying that you want multiple subdomains pointing to the same place. For example would *.example.com work? to tell it all subdomains or any non existing sub domain to point it to the same place. How can I specify all subdomains except X one where it would be pointing to another place. I will assume I would add the X subdomain below the setup for the *.example.com yes?

Yep.

If you use a wildcard though, you’ll need to configure the DNS challenge, and grab a build of Caddy with the appropriate DNS plugin.

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