[Solved] phpMyAdmin as subdirectory of localhost

Path matching in Caddy is exact, so /phpmyadmin will only match exactly /phpmyadmin and nothing else.

But I don’t recommend using path matchers in site addresses, it more complicated than necessary. Best to use handle blocks, which reduce ambiguity in the config.

You’ll also need file_server so that Caddy serves the static files (like HTML, JS, CSS) that it’ll serve.

Also, I generally recommend using subdomains rather than subpaths. Many apps don’t behave well when proxied under a subpath (I know that phpmyadmin generally works well though). Explained here:

You can instead use a subdomain like phpmyadmin.localhost which will automatically resolve to 127.0.0.1 on most Linux systems.

http://phpmyadmin.localhost {
	root * /var/www/html/phpmyadmin
	php_fastcgi unix//run/php-fpm/www.sock
	file_server
}
1 Like