Wordpress Multisite htaccess rewrites

1. Caddy version (caddy version):


2. How I run Caddy:

a. System environment:

Ubuntu 20.04

b. Command:

paste command here

c. Service/unit/compose file:

paste full file contents here

d. My complete Caddyfile or JSON config:

# Caddyfile

# Global options
	# TLS Options

	# Server Options
	servers {
		protocol {

# Inheritated config
(common) {
    encode zstd gzip
    php_fastcgi unix//run/php/php-fpm.sock

(rewriteRule) {

testurl123.com {
	root * /var/www/html
	import common
	import rewriteRule

	@disallowed {
    path /xmlrpc.php
    path *.sql
    path /wp-content/uploads/*.php
    rewrite @disallowed '/index.php'

    header {
    # Enable HTTP Strict Transport Security (HSTS) to force clients to always
    # connect via HTTPS (do not use if only testing)
    Strict-Transport-Security "max-age=31536000;"
    # Enable cross-site filter (XSS) and tell browser to block detected attacks
    X-XSS-Protection "1; mode=block"
    # Prevent some browsers from MIME-sniffing a response away from the declared Content-Type
    X-Content-Type-Options "nosniff"
    # Disallow the site to be rendered within a frame (clickjacking protection)
    X-Frame-Options "DENY"
    # Be extremely restrictive.
    # https://developers.google.com/web/fundamentals/security/csp/
    Content-Security-Policy "default-src 'none'; block-all-mixed-content"
    Cache-Control "no-cache, no-store, must-revalidate"

	# log
	# folder needs to be created --> mkdir caddy
	# owner needs to be set --> chown -R caddy /var/log/caddy
	# restart caddy --> systemctl restart caddy
	log {
		output file /var/log/caddyaccess.log {
			roll_size 20mb
		format console

3. The problem I’m having:

Has anyone already adapted the htaccess rewrite rules for wordpress multisite in caddy syntax?

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

4. Error messages and/or full log output:

5. What I already tried:

6. Links to relevant resources:

“Step 4: Enabling the Network”

Caddy’s default behaviour for php_fastcgi should already do this for you.


You’re right! I have made a mistake, I missed this crucial line in wp-config: database - I have a problem with my WordPress DB after I tried to install multi-site - WordPress Development Stack Exchange

Now it is fully working. :grinning: Thank you!