Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caddy configuration for Wordpress multisite

I'm trying to setup a Wordpress website with multisite:

  • example.com

  • example.com/fr

With the following Caddyfile:

example.com:80 {
    redir https://www.example.com{uri}
}

www.example.com:80 {
    root /app/public
    gzip

    fastcgi / 127.0.0.1:9000 {
        ext .php
        split .php
        index index.php
    }

    rewrite {
        regexp ^/[_0-9a-zA-Z-]+(/wp-.*)
        to {path} {path}/ {1}
    }

    rewrite {
        regexp ^/[_0-9a-zA-Z-]+(/.*\.php)$
        to {path} {path}/ {1}
    }

    rewrite {
        if {path} not_match ^\/wp-admin
        to {path} {path}/ /index.php?_url={uri}
    }

    log stdout
    startup /usr/sbin/php-fpm7.0 -F -O &
}

When I reach /fr/wp-admin/, I get a 301 to /wp-admin/.

Does anybody know how to fix that ?

like image 930
Samber Avatar asked Jun 20 '16 08:06

Samber


1 Answers

This caddy config works for me. Hope this helps.

rewrite {
    regexp ^(/[^/]+)?(/wp-.*)
    to {2}
}

rewrite {
    regexp ^(/[^/]+)?(/.*\.php)
    to {2}
}

rewrite {
    if {path} not_match ^\/wp-admin
    to {path} {path}/ /index.php?{query}
}
like image 190
user1949536 Avatar answered Nov 01 '22 10:11

user1949536