Apache2 + Caddy web configuration?

I use the MediaWiki software and want to migrate their Apache2 configuration to Caddy:

RewriteCond %{REQUEST_URI} !^/w/rest\.php
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/w/index.php [L]

But does this also rewrite /index.php?title= to /wiki/? And what is the configuration of this for Caddy?

This is probably all you need:

example.com {
	root * /var/www/html/w
	encode gzip

	@title `!file() && path_regexp('title', '^/(.*)$')`
	rewrite @title /index.php?title={re.title.1}&{query}

	php_fastcgi unix//var/run/php/php8.3-fpm.sock

Sourced from https://www.reddit.com/r/selfhosted/comments/18jgreo/mediawiki_and_caddy/ and slightly modified for simplicity

If you can, I suggest reaching out to the MediaWiki folks so they could add something like this to their docs. Let them know they can reach out to us for help if they need it. (We’re not users of MediaWiki, so best if a user reaches out).

Holy, is that complex! Someone should really write a configuration editor for Caddy, where one can easily configure everything to any wesie

Huh? That’s not complex at all. That’s your entire config to run your site, including TLS automation, compression, PHP, static files, and the rewrite for ?title=.

This is all stuff you can learn easily from the docs.

Definitely not from the Caddy docs! It doesn’t even say anything about regex

Yes it does.