我正在尝试将一个网站配置为另一个网站的子位置。更多背景信息,我有 wp1 和 wp2,都是 wordpress 网站,而 wp2 需要是 wp1 的子位置,例如http://wp1.com/wp2但我找不到实际的方法,我阅读了可用的文档,但仍然找不到为什么它实际上不起作用。
我的 nginx 配置文件:
server {
listen 80;
listen [::]:80 ;
server_name 1.2.3.4; #(IP)
root /var/www/html/wp1;
index index.php;
client_max_body_size 200M;
satisfy any;
allow 1.2.3.4;
deny all;
auth_basic "Restricted"; #For Basic Auth
auth_basic_user_file /etc/nginx/.htpasswd; #For Basic Auth
location /wp2 {
root /var/www/html/wp2;
index index.php;
try_files $uri $uri/ /index.php?$args;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include fastcgi_params;
}
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include fastcgi_params;
}
}