【问题标题】:Nginx, MODx & Xenforo, living together -> .conf challengeNginx、MODx 和 Xenforo,共同生活 -> .conf 挑战
【发布时间】:2017-10-30 08:59:11
【问题描述】:

我在配置 nginx 以从一个域同时为 Xenforo 和 MODx 提供服务时遇到了很大的困难。我已经尝试了数百次调整,尽我所能阅读所有内容,几乎可以正常工作......但没有雪茄。

问题的症结似乎是 MODx 重写劫持了我的 xenforo /xf/ 位置,并且没有 /xf/ URL 可以解决任何问题,而是触发 MODx 默认 404 错误页面。

完整的服务器块是;

server {

## HTTPS server essentials
listen  443;
server_name  www.mysite.com.au;

## Common Server block SSL config 
include "/opt/bitnami/nginx/conf/bitnami/ssl-apps.conf";    



## Xenforo location
location ^~  /xf/   {
    root /opt/bitnami/apps/xenforo;

    ## SEO friendly urls    
    try_files $uri $uri/ /xf/index.php?$uri&$args;

    location ~ \.(php)$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_read_timeout 300;
        fastcgi_pass unix:/opt/bitnami/php/var/run/www.sock;
        fastcgi_index index.php;
        fastcgi_ignore_client_abort on;
        fastcgi_param  SCRIPT_FILENAME $request_filename;
        include fastcgi_params;
    }

}


## MODx 
root /opt/bitnami/apps/mysite.com.au/htdocs;

try_files $uri $uri/ ;

    location ~ \.(php|html)$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_read_timeout 300;
    fastcgi_pass unix:/opt/bitnami/php/var/run/www.sock;
    fastcgi_index index.php;
    fastcgi_ignore_client_abort on;
    fastcgi_param  SCRIPT_FILENAME $request_filename;
    include fastcgi_params;
    }

    if (!-f $request_filename) {
    rewrite ^/(.*)$ /index.php?q=$1 last;
    }

}

但是,如果我将 MODx 正则表达式改写为;

 ^/(.*).html$ 

然后 100% 的 xenforo URI 的解析和所有几乎工作除了没有尾随 /index.html 的 MODx 目录 uri 不解析(即 www.mysite.com.au/content1/ 将失败) .

我研究了级联优先级的迷宫,并承诺在过去 10 小时内测试至少 80 种或更多变体。无论我尝试什么,我都无法通过 MODx 重写获得 /xf/ 路径。

出于多种原因,我需要解析目录路径,其中最重要的是多年的 SEO 工作。

任何建议表示赞赏

【问题讨论】:

    标签: mod-rewrite nginx modx xenforo


    【解决方案1】:

    得到它的工作;

    rewrite ^/(.*).html$ /index.php?q=$1 last;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-25
      • 2019-12-26
      • 2014-12-21
      • 2018-01-21
      相关资源
      最近更新 更多