如何在foo.example上有一个Wordpress网站,在foo.example / bar上有另一个Wordpress网站?

时间:2018-04-17 20:08:59

标签: php wordpress dns subdomain web-hosting

我有一个仅在PHP 5.2中运行的遗留WordPress博客(在更高版本中有许多不兼容性),我正在开发一个应该在PHP 7中运行的新Wordpress博客。

要求新博客的网址为foo.example,遗留在foo.example/bar

由于PHP版本不同,每个版本都托管在不同的计算机上。到目前为止,我得到的最接近的是有一个子域名bar.foo.example指向旧版博客,但无法让foo.example/bar做同样的事情(甚至不知道它是否是&#39} ;可能)。

我很乐意为这项任务提供一些帮助,并且我愿意接受新的替代方案。

2 个答案:

答案 0 :(得分:0)

根据您的服务器软件,我知道您可以在NGINX中执行某些操作:

server {
    server_name domain.tld;
    root /var/www/wordpress;

    index index.php;

    ...

    location / {
            try_files $uri $uri/ /index.php?$args;
    }

    location /bar/ {
            root /var/www/wordpress-legacy;
            try_files $uri $uri/ /index.php?$args;
    }


    ...
}

答案 1 :(得分:0)

您无法根据请求路径指向不同的服务器 - 域将始终指向一个服务器(至少从用户角度来看)。但是,这个服务器可以作为代理服务器并从正确的服务器提供内容。潜在的解决方案:

  1. 将负载均衡器放在这两台服务器的前面 - 请参阅HAProxy - URL Based routing with load balancing
  2. 将新服务器配置为代理,以便从旧服务器为子目录提供内容。例如,使用NGINX Reverse Proxy

    location /bar/ {
        proxy_pass http://legacy.foo.example/bar/;
    }