@rahul286
I think it’s finally working.
To sum it up:
in wp-config.php I changed
$base = '/blogs';
define('PATH_CURRENT_SITE', '/blogs/');
I changed the path in wp-site and wp-blogs to /blogs/
This was my server config for the example.com server:
map $uri $blogname{
~^(?P<blogpath>/[_0-9a-zA-Z-]+/)files/(.*) $blogpath ;
}
map $blogname $blogid{
default "";
/testblog/ 2;
#/site2/ 3;
}
server {
server_name example.com ;
access_log /usr/local/nginx/logs/access.log;
error_log /usr/local/nginx/logs/testwp.log debug;
root /usr/local/nginx/htdocs ;
index index.php;
if ($request_uri ~* "^/blogs(/[_0-9a-zA-Z-]+)?/files/(.*)"){
set $rtfile $2;
}
location ~ ^/blogs(/[_0-9a-zA-Z-]+)?/files/(.*)$ {
try_files /wp-content/blogs.dir/$blogid/files/$rtfile /wp-includes/ms-files.php?file=$rtfile ;
access_log off; log_not_found off; expires max;
}
#avoid php readfile()
location ^~ /blogs.dir {
internal;
alias /usr/local/nginx/htdocs/blogs/wp-content/blogs.dir ;
access_log off; log_not_found off; expires max;
}
if (!-e $request_filename) {
# wp-admin to wp-admin/
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
#other wp-* files/folders
rewrite ^/blogs(/[_0-9a-zA-Z-]+)?(/wp-.*) /blogs$2 last;
#other php files
rewrite ^/blogs(/[_0-9a-zA-Z-]+)?(/.*\.php)$ /blogs$2 last;
}
location / {
try_files $uri $uri/ /blogs/index.php?$args ;
}
location ~ \.php$ {
try_files $uri /blogs/index.php;
include /usr/local/nginx/conf/fastcgi-php.conf;
fastcgi_pass 127.0.0.1:10004;
}
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 = /favicon.php { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location ~ /\. { deny all; access_log off; log_not_found off; }
}
Many thanks to you Mika and Pothi.
With the above config (and having seen my other config) do you have any suggestions now for redirecting non-/blogs URLs back to https://www.example.com?