Read redirects from file

I saw some time ago someone post on Twitter how they got their Caddy server to read a list of redirects from a file generated by Hugo’s alias feature.

I’m looking at implementing it now and I can’t for the life of me find the post anymore. Does anyone have any idea how this could be achieved? Hugo can generate a list of aliases in basically any format since it can just generate them using a Golang template, so I guess its just a matter of getting them into Caddy somehow?

I’m using Caddy v2.1.1 on Linux. Happy to build in whatever config adapters are required if thats needed!

Yep, you can use the import directive which will read in Caddyfile tokens from another file, and your files can contain redir directives.


That’s exactly what I’m looking for. Thanks so much!

1 Like

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