【问题标题】:Wordpress + Nginx: 'Site within Site'Wordpress + Nginx:“站点内的站点”
【发布时间】:2015-10-27 03:28:52
【问题描述】:

假设我使用nginxexample.com 安装并提供了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;
    }

}

【问题讨论】:

  • 我不确定是否有更好的方法,即不同的服务器块和其他形式的隐形重写。
  • 这看起来不像是stackoverflow问题,更像是服务器故障。您能否在 ngnix 的调试中查看 HTTP 请求 URI 以查看请求网站

标签: php wordpress nginx


【解决方案1】:

在主 wordpress 文件中移动子目录并使用以下内容更容易:

# Micro site
location /microsite/ {
    try_files $uri $uri/ /microsite/index.php?$args;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-21
    • 1970-01-01
    • 2018-06-15
    • 2011-09-08
    • 1970-01-01
    • 2011-03-30
    • 1970-01-01
    相关资源
    最近更新 更多