Caddy's php_fastcgi shorthand abstracts the complexity of FastCGI headers and try_files rules. Generate a ready-to-use Caddyfile for your PHP application here.
The php_fastcgi directive is a shortcut for the usual rewrite and FastCGI proxy rules, including front-controller routing.
example.com {
root * /var/www/example.com/public
php_fastcgi unix//run/php/php8.4-fpm.sock
file_server
}php_fastcgi must sit before file_server so PHP requests are handled by FPM and static assets still fall through to the file server.
No, php_fastcgi already matches .php paths and rewrites directory and missing-file requests to index.php.