I’m trying to host wordpress on caddy. I’ve used the configuration but with mixed success:
Attempt #1: Conventional wordpress on subdomain
blog.example.com {
root /var/www/wordpress
gzip
fastcgi / /run/php/php7.0-fpm.sock php
rewrite {
if {path} not_match ^\/wp-admin
to {path} {path}/ /index.php?_url={uri}
}
}
This works perfectly well, except that it is on a subdomain, which is not what I want to optimally have.
Attempt #2: Wordpress on subdirectory, without rewrite
www.example.com/blog {
root /var/www/wordpress
gzip
fastcgi / /run/php/php7.0-fpm.sock php
}
This works fine as well. Except that I can’t activate pretty permalinks feature on wordpress.
Attempt #3: Wordpress on subdirectory, with rewrite
www.example.com/blog {
root /var/www/wordpress
gzip
fastcgi / /run/php/php7.0-fpm.sock php
rewrite {
if {path} not_match ^\/wp-admin
to {path} {path}/ /index.php?_url={uri}
}
}
Here’s where the trouble comes in. I am able to display index.php
albeit without any css (it couldn’t load). Additionally I can’t access the wp-admin
section of the site, etc.
Other variants of rewrite tried include:
rewrite {
if {path} not_match ^\/blog\/wp-admin
to {path} {path}/ /index.php?_url={uri}
}
rewrite {
if {path} not_match ^\/wp-admin
to {path} {path}/ /blog/index.php?_url={uri}
}
rewrite {
if {path} not_match ^\/blog\/wp-admin
to {path} {path}/ /blog/index.php?_url={uri}
}
They don’t work as well. I must have misunderstood some parts of the rewrite function, but I just can’t wrap my head around why the same code cannot work on a subdirectory configuration when it works fine on a normal domain.
Appreciate all the help I can get!
EDIT:
I thought it may be relevant to point out that my domain is currently using this configuration:
www.example.com {
proxy / localhost:8001 {
except /static
except /shop
except /blog
transparent
}
}