We have a customer with an existing Wordpress site they are happy with but they would like the core function replace which sits in a folder called /directory
Is it possible to send all traffic to /directory to a different .php file? Eg rename the Laravel index.php to laravel-index.php so all Wordpress requests are handled by index.php still?
We could stick it on a sub domain but it would be more seamless this way.
Why, though? If the virtual hosts and proxies are set up properly on Nginx or Apache, Laravel would be served the same. It's basically same thing as setting up Nuxt with Laravel as API served via /api route instead of a subomain.
If I assumed correctly, the author wants to keep the main website running on Wordpress, but serve a Laravel app on the same domain. Then they can certainly put wordpress on one directory and laravel in the other directory, set up hosts for different locations and root folders, and run it side by side.
Otherwise, the issue hasn't been described clearly and I'm assuming wrong.
No I did not, and I'm not talking about using a subdomain. I'm talking about placing wordpress in one directory, the Laravel app in another, and then routing the traffic via server configuration so the requests to mysite.com would lead to a wordpress site, and the laravel app would be served when the user goes to, say, mysite.com/control-panel. It's all done by setting up vhosts in Nginx or Apache, basically. The main host uses / as a location parameter and the wordpress public directory as root, and Laravel app's host utilizes, say, /control-panel as a location and point to its public directory. If I'm not mistaken, it's done under the same vhost even, only with specifiying the different location blocks.
More simply than this we can simply preserve the Laravel htaccess file and add a line to grab all the non /control-panel requests and point them at the Wordpress index.php instead of the Laravel index.php