NGinx + Wordpress Subdomain Multi with core in Subdirectory
I have a WordPress install that works perfectly on a Apache server. I am currently in the process of both changing my hosting company (the new one offer NGinx) and my development stack (moving to vvv).
Here is how the install is set-up:
It a Wordpress sub-domain multi-site install, with core in a sub-folder (/wp-app/), wp-content in another sub-folder (/wp-app-content/) and of course my index.php, wp-config.php and .htaccess in the root folder together with these 2 folders.
Here is my problem :
On the production version (apache), the admin works perfectly and the /wp-app/ folder is completely hidden. On the dev version (NGinx), the admin partially works but a lot of pages return a 404 and sometimes WP rewrite the url with wp-app.
What I think is the source of the problem :
I'm almost certain my NGinx rewrites are not good. I have found several feeds mentioning the issue, but they were either unanswered or the answer was partial and wasn't working for me.
My .htaccess file that works :
# BEGIN WordPress
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-app/$1 [L]
RewriteRule ^(.*\.php)$ wp-app/$1 [L]
RewriteRule . index.php [L]
# END WordPress
My nginx.conf that partially works :
server {
listen 80;
listen 443 ssl;
server_name guillaumemolter.dv *.guillaumemolter.dv
root /srv/www/guillaumemolter/htdocs;
index index.php;
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ last;
rewrite ^/(wp-.*.php)$ /wp-app/$1 last;
rewrite ^/(wp-(content|admin|includes).*) /wp-app/$1 last;
}
location / {
#try_files $uri $uri/ /wp-app/index.php?$args ;
try_files $uri $uri/ /index.php?$args ;
}
location ~ \.php$ {
#try_files /wp-app/$uri =404;
try_files $uri =404;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}
location = /robots.txt { access_log off; log_not_found off; }
location ~ /\. { deny all; access_log off; log_not_found off; }
}
The 2 commented lines are tests I made out of desperation....
Resources I read and used so far:
https://codex.wordpress.org/Nginx https://rtcamp.com/wordpress-nginx/tutorials/multisite/ And others, including 2 feeds from this site, that I can't post here because I don't have enough reputation.
Thank you very much for your help.