WordPress Pretty Permalinks in Caddy v2

Hey @francislavoie, good morning.

So I’ve been doing a bit of debugging, and I may have found something related?

In WordPress there’s this function got_url_rewrite() in /wp-admin/includes/misc.php:45. I can see it’s checking for the presence of Apache’s mod_rewrite, nginx, and IIS permalinks, but nothing related to Caddy specifically.

If I modify this function to always return true, or detect Caddy via headers, it appears to be working, and the URLs no longer have the index.php string.

Appreciate that this isn’t part of Caddy directly, but perhaps an additional check could be included as part of this function, in order to detect Caddy?

/**
 * Returns whether the server supports URL rewriting.
 *
 * Detects Apache's mod_rewrite, IIS 7.0+ permalink support, and nginx.
 *
 * @since 3.7.0
 *
 * @global bool $is_nginx
 *
 * @return bool Whether the server supports URL rewriting.
 */
function got_url_rewrite() {
	$got_url_rewrite = ( got_mod_rewrite() || $GLOBALS['is_nginx'] || iis7_supports_permalinks() );

	/**
	 * Filters whether URL rewriting is available.
	 *
	 * @since 3.7.0
	 *
	 * @param bool $got_url_rewrite Whether URL rewriting is available.
	 */
	return apply_filters( 'got_url_rewrite', $got_url_rewrite );
}