Mapping Domains To Directories via a file (RewriteMap)

I would like to move a server over from apache to caddy, but it uses RewriteMap to assign a domain to a directory based on the contents of a text file. The file looks like this: /home/webserverfiles/somedirectory /home/webserverfiles/whatever /home/webserverfiles/abcdefg

and can be updated dynamically (adding or removing entries) without restarting apache.

Does caddy have this ability?

Yeah, you can do this with the map directive:,, {
	map {host} {root} { /home/webserverfiles/somedirectory /home/webserverfiles/whatever /home/webserverfiles/abcdefg

	root * {root}


You just need to reload Caddy after modifying the config (no downtime). You can break this out into a separate file with import.


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