Roots.io Bedrock - WordPress + (sub-domain | sub-directory) + Caddy

UPDATE:

1) The WP+Bedrock with multisite-url-fixer is working and running with Caddy.

2) The part of “translation” from Apache to Caddyfile, still doesn’t work properly.


Hello,

I have tried to install the roots.io Bedrock from Composer.

completely solved
  1. composer create-project roots/bedrock
  2. add define('WP_ALLOW_MULTISITE', true); into application.php
  3. composer require roots/multisite-url-fixer
  4. after, added into application.php (this time, I have tried to use subdomain install)
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', true);
    define('DOMAIN_CURRENT_SITE', 'dev.mysite.tld');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);
  1. define Caddyfile:
    (wpmu) {
        rewrite {
            if {path} not_match ^(\/wp)(\/wp-admin)(\/network)?
            to {path} {path}/ /index.php?{query}
        }
    }
    :80 {
        redir 308 {
            if {>X-Forwarded-Proto} is http
            / https://{host}{uri}
        }
    }
    www.dev.mysite.tld {
        redir https://dev.mysite.tld{uri}
    }
    dev.mysite.tld {
        root /var/www/dev.mysite.tld/bedrock/web
        import tls-cloudflare
        timeouts 1h
        import compact
        import php72-fpm-sock
        import directive-cors
        import http-header
        import wpmu
    }
partially solved

The problem:

After choose subdomain and login/wp/wp-admin, the network (top menu WP admin) gives /wp-admin/network instead /wp/wp-admin/network path. The left admin WP menu for the main website is ok.

Note: When I use Apache, everything is ok.

The configuration that WordPress/Bedrock gaves me when I choose multi-site.
:point_down:

=== WORDPRESS BEDROCK SUB-DIRECTORY ===
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) wp/$2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ wp/$2 [L]
RewriteRule . index.php [L]

:point_down:

=== WORDPRESS BEDROCK SUB-DOMAIN ===
RewriteEngine On
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).*) wp/$1 [L]
RewriteRule ^(.*\.php)$ wp/$1 [L]
RewriteRule . index.php [L]

What I read:

Many other attempts that I have tried for wpmu snippet.

attempt 01:

(wpmu) {
	rewrite {
		if {path} not_match ^(\/wp)?(\/wp-admin(\/network)?)
		to {path} {path}/ {path}/index.php /index.php/{query}
	}
	rewrite {
		r ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)
		to wp/${2}
	}
	rewrite {
		if {path} not_match ^(\/wp)?(\/wp-admin(\/network)?)
		r ^([_0-9a-zA-Z-]+/)?(.*\.php)$
		to wp/${2}
	}
}

attempt 02:

(wpmu) {
	rewrite {
		if {path} not_match ^(\/wp)(\/wp-admin)(\/network)?
		to {path} {path}/ /index.php?{query}
	}
	rewrite {
		if_op or
		if {path} match ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)
		if {path} match ^([_0-9a-zA-Z-]+/)?(.*\.php)$
		to wp/{2}
	}
}
partially solved

attempt 03:

Note: Works partially, not entirely.

(wpmu) {
    rewrite {
        if {path} not_match ^(\/wp)(\/wp-admin)(\/network)?
        to {path} {path}/ /index.php?{query}
    }
}

Any help will be appreciated. Thank you very much.

I’m not sure what errors you are getting.

Can you see what the paths are being rewritten to?

If you use {rewrite_url} or {rewrite_uri} in your log you will be able to see what the origional urls are being rewritten to, this may help you to debug the issue?

log / c:/logs/mylogfile.log “{common} {rewrite_uri}”

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.