Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rohan0793's avatar

How to host a Laravel application at a route of another Laravel application?

I have a Laravel application hosted at mydomain.com, and now I have another Laravel application that I would like to host at mydomain.com/email. I went through a guide on https://serversforhackers.com/c/nginx-php-in-subdirectory and it made a lot of sense to me, and worked perfectly.

But the company I work for uses Apache2 on production and I am trying to translate this configuration to apache 2. But I am not sure how.

Here is what I have done so far. I have added Alias /email /dir/of/nested/laravel/app/public to my main laravel application's apache config.

With this the routes on mydomain.com/email no longer show a 404 from Laravel side, but now they are being redirected to the nested application, I know this because going to mydomain.com/email redirects me to mydomain.com/email/login. But now I trying to figure out what do I need to change in the .htaccess of the nested Laravel app to make the work, because I see a 404 from Apache on all routes of /email.

Any ideas anyone? Will it require some kind of a Rewrite rule?

Also how good is this is solution? Will I be restricted to one server because of this? Will it be scalable?

In one of the forums, I saw someone mention that they had a similar architecture, but they used a load balancer to redirect all the nested laravel app routes, is that a better solution than this?

0 likes
1 reply
artcore's avatar

I have several staging domains on one laravel instance.

Create a public folder and add index.php with path to autoload of the main app. Doing a bit of magic with middleware and config setting on runtime by checking the domain and voila.

I change database, domain cookie and static files directory via middleware and also add the logged in user to the request user resolver. Sounds involved but it's fairly straightforward.

As for scalability, it's still one laravel app but with multiple DBs. Should be able to run in a cloud

Please or to participate in this conversation.