I am migrating my app from PHP 5.6 to php 8.0 by having a front controller redirecting to my legacy app or my new app depending on the uri.
I tried with alias and it works but I need to keep the exact same host for both and no alias.
Eg:
https://foo.bar.com/my_php80_routes
https://foo.bar.com/my_php56_routes
Here is my unsatisfaying try with alias
<VirtualHost *:80>
ServerName foo.bar.com
DocumentRoot /var/www/html/foobar/public
# Unwanted prefix
Alias /legacy /var/www/html/foobar/legacy/web
<Directory /var/www/html/foobar/public>
AllowOverride none
Require all granted
SetEnv APP_ENV "dev"
# Handled by php8.0 : ok
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php/php8.0-fpm.sock|fcgi://localhost/"
</FilesMatch>
FallbackResource /index.php
DirectoryIndex index.php
</Directory>
<Directory /var/www/html/foobar/legacy/web>
AllowOverride none
Require all granted
# Handled by libapache2-mod-php5.6 : ok
FallbackResource /app_dev.php
DirectoryIndex app_dev.php
</Directory>
ErrorLog /var/log/apache2/foobar.log
CustomLog /var/log/apache2/foobar.log combined
</VirtualHost>
I searched for another method, maybe based on a custom HTTP Header like "FOOBARAPP_LEGACY: 1" but I didn't find a way to map HTTP HEADER to a filesystem location with Apache.
Is there any other solution ?
[edit]
I will try to explain myself better.
What I am trying to achieve is having 2 applications each running on a different PHP version, one being the "Main App" (the new app on PHP8.0) and redirecting to the "Second App" if route is not found by "Main App".
All of this being completly transparent to the end user. (same domain, no prefix)
If https://foo.bar.com/posts is not yet migrated : Main App doesn't find the route and redirects to Second App that will serves the content.
When this endpoit is migrated to "Main App" : Main App find the route and serves the content.
So I'm asking a solution that doesn't involve a /prefix or a new subdomain.