1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[WordPress][Nginx] サブディレクトリにサブディレクトリ型のマルチサイトWordPressを設置する際の Nginx 設定

Posted at
set $proxy_https '';
if ($http_x_forwarded_proto = 'https') { set $proxy_https 'on'; }
if ($http_cloudfront_forwarded_proto = 'https') { set $proxy_https 'on'; }
if ($scheme = 'https') { set $proxy_https 'on'; }

rewrite ^(/[^/]+)/files/$ $1/index.php last;
rewrite ^(/[^/]+)/[_0-9a-zA-Z-]+/files/$ $1/index.php last;

if (!-e $request_filename) {
    rewrite ^(/[^/]+)/[_0-9a-zA-Z-]+/wp-json/.*$ $1/index.php$is_args$args last;
    rewrite ^(/[^/]+)/[_0-9a-zA-Z-]+(/wp-.*)$ $1$2 last;
    rewrite ^(/[^/]+)/[_0-9a-zA-Z-]+(/wp-admin/.*\.php)$ $1$2 last;
    rewrite ^(/[^/]+)/[_0-9a-zA-Z-]+(/.*\.php)$ $1$2 last;
    rewrite ^(/[^/]+)/[_0-9a-zA-Z-]+/?.*$ $1/index.php$is_args$args last;
}

location ~ ^(/[^/]+)/.*$ { try_files $uri $uri/ $1/index.php$is_args$args; }
location / { try_files $uri $uri/ /index.php$is_args$args; }

location ~ \.php$ {
    expires        off;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass   phpfpm;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  HTTPS            $proxy_https  if_not_empty;
    fastcgi_param  HTTP_PROXY       "";
    include        fastcgi_params;
    fastcgi_intercept_errors on;
    fastcgi_connect_timeout  60;
    fastcgi_send_timeout     180;
    fastcgi_read_timeout     180;
    fastcgi_buffers          16 16k;
    fastcgi_buffer_size      32k;
    fastcgi_busy_buffers_size 32k;
    fastcgi_temp_file_write_size 256k;
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?