0

I have a legacy WordPress blog that runs only in PHP 5.2 (lot's of incompatibilities in later versions), and I am developing a new Wordpress blog that should run in PHP 7.

The requirement is that the new blog have an URL of foo.example, and the legacy would be in foo.example/bar.

Due to different PHP versions, each one is hosted in a different machine. Until now, the closest I got was having a subdomain bar.foo.example pointing to the legacy blog, but couldn't make foo.example/bar do the same thing (don't even know if it's possible).

I would gladly apreciate some help with this task and I'm open to new alternatives.

Patrick Mevzek
  • 10,995
  • 16
  • 38
  • 54
  • You need to understand that the DNS resolution operates only on the hostname and not the path, so `foo.example` and `foo.example/bar` will arrive to the same host. There, the host could be configured to redirect or proxy one of the path to another host. – Patrick Mevzek Apr 17 '18 at 21:28

2 Answers2

0

Depending on your server's software, I know you can do something like in 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;
    }


    ...
}
Aidan H
  • 124
  • 9
0

You can not really point to different server based on request path - domain will always point to one server (at least from user perspective). However this one server could work as a proxy and serve content from correct server. Potential solutions:

  1. Put a load balancer in front of this two servers - see HAProxy - URL Based routing with load balancing.
  2. Configure new server as a proxy to serve content from legacy server for subdirectory. For example by using NGINX Reverse Proxy:

    location /bar/ {
        proxy_pass http://legacy.foo.example/bar/;
    }
    
rob006
  • 21,383
  • 5
  • 53
  • 74