banner
李大仁博客

李大仁博客

天地虽大,但有一念向善,心存良知,虽凡夫俗子,皆可为圣贤。

[Wordpress] 子目录下WP建站Nginx反向代理设置

子目录下 WP 建站 Nginx 反向代理设置 参考官方文档,两种方式一下都可以实现要求

方法 1,rewrite 方式,适用 php-fpm location /替换子目录名称/ { index index.html index.php; if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; } if (!-f $request_filename){ rewrite (.*) /替换子目录名称/index.php; } } 方法 2,使用 try_files 方式 location /替换子目录名称/ { index index.php; try_files $uri $uri/ /替换子目录名称/index.php?$args; }

必须要做的,把 wp-admin 单独处理 rewrite /替换子目录名称/wp-admin$ $scheme://$host$uri/ permanent;

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.