Hopefully someone out there has encountered this before because we haven't been able to find a solution yet.
Currently, we have two different frameworks installed on our server's root directory (/home/username
). One of these is a micro framework for serving a very fast API. The other is a Laravel. The directory paths relevant to this question are below:
-
/home/username/public_html
(the server's publicly accessible directory) -
/home/username/microframework/public
(the public folder for the micro framework) -
/home/username/laravel-project/public
(the public folder for our Laravel project)
Our goal is to be able to provide multiple prefixes that get routed to the appropriate framework. For example
www.domain.com/api/login --> goes to route /api/login on the micro framework
www.domain.com/account/login --> goes to route /account/login on Laravel
www.domain.com/admin/login --> goes to route /admin/login on Laravel
Attempt #1
The first thing we tried was using symbolic links to direct traffic to the different frameworks
ln -s /home/username/microframework/public/api /home/username/public_html/api
ln -s /home/username/laravel-project/public/account /home/username/public_html/account
ln -s /home/username/laravel-project/public/admin /home/username/public_html/admin
And then in Laravel's routes.php
file, we have
Route::get('/account/login', 'AccountController@showLogin');
Route::get('/admin/login', 'AdminController@showLogin');
The issue we have encountered is that we get 403 and 404 errors when using this strategy.
You don't have permission to access /account/login on this server
It seems that we aren't allowed to create a symbolic link that goes to a fake directory (since /home/username/laravel-project/public/account
and /home/username/laravel-project/public/admin
do not exist). I would have thought this was possible, but it seems not.
Attempt #2
As an alternative, we tried the following approach. We created symbolic links that pointed directly to the framework's public folders.
ln -s /home/username/microframework/public /home/username/public_html/api
ln -s /home/username/laravel-project/public /home/username/public_html/account
ln -s /home/username/laravel-project/public /home/username/public_html/admin
This works, however, we loose the /account
and /admin
prefixes from our routing. Our Laravel routes.php only worked if it looked like this:
Route::get('/login', 'AccountController@showLogin');
//Route::get('/login', 'AdminController@showLogin'); // this causes conflict since the /login route is already defined
It seems that you can't filter based on the url PRIOR to the public folder, thus the /account
and /admin
prefixes were not available to define routing. Perhaps there is a setting that would enable this, but we were unable to find it.
So we have two options, but have been unable to get either one working.