假设我使用example.com
在nginx
安装了wordpress并提供了服务。
我希望example.com/microsite
由另一个根目录中的单独wordpress安装提供服务。
我已经包含了我的nginx配置无效。拨打/microsite
的电话会传到主网站的index.php
,我会收到404。
server {
listen 80;
server_name example.com;
return 301 https://www.example.com$request_uri;
}
server {
listen 80;
server_name www.example.com;
return 301 https://www.example.com$request_uri;
}
server {
listen 443;
ssl_certificate /etc/ssl/certs/Example.pem;
ssl_certificate_key /etc/ssl/private/example.key;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
server_name www.example.com;
root /var/www/www.example.com;
index index.php;
access_log off;
client_max_body_size 15M;
gzip on;
########## BEGIN MICRO-SITES
# Mini Site Conference
location /minisite/ {
root /var/www/minisite;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
#END Mini Site Conference
######### END MICRO-SITES
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_intercept_errors on;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
答案 0 :(得分:0)
更容易移动主WordPress文件中的子目录并使用以下内容:
# Micro site
location /microsite/ {
try_files $uri $uri/ /microsite/index.php?$args;
}