PHP wild cards for subdomains

Just started to play with Caddy and I intend to use it on a domain name with multiple sub-domains. They all use php-cgi and to get them working properly I have to redeclare the fastcgi directive in all sub-domain block.

Is there any way to achieve this with wild cards? Like this:

example.com {
	root /var/www
	fastcgi / /var/run/php/php7.0-fpm.sock {
		ext 	.php
		split	.php
		index	index.php
	}
}

*.example.com {
	fastcgi / /var/run/php/php7.0-fpm.sock {
		ext 	.php
		split	.php
		index	index.php
	}
}

subdomain1.example.com {
	root /var/www/allowip
	gzip
}

subdomain2.example.com {
	root /var/www/plp
	gzip
}

The Caddyfile does not have inheritance, or wildcards in the sense that you want.

But you can simplify your fastcgi config to just one line:

fastcgi / /var/run/php/php7.0-fpm.sock php

And then you can easily put that in each site that needs it, because it is only a single line.

Some people like to use import to share common configuration, but for just one line it’s not benefitting you much.

Thank you for that php one-liner. I will aslo have a look to the import function as I have more common options to configure.

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