So basically my issue is about the routing of a subdomain (or multiple ones) to a single Laravel app. To go more in details I have multiple Route::group and I want to have them "connect" to a specific subdomain. For example:
- account.domain.co →
Route::domain('account.domain.co')→group(...
- visual.domain.co →
Route::domain('visual.domain.co')→group(...
I have configured my Virtual Hosts like so:
<VirtualHost *:443>
ServerName domain.co
DocumentRoot /var/www/domain/public
DirectoryIndex index.php
[...]
</VirtualHost>
<VirtualHost *:443>
ServerName account.domain.co
DocumentRoot /var/www/domain/public
DirectoryIndex index.php
[...]
</VirtualHost>
<VirtualHost *:443>
ServerName visual.domain.co
DocumentRoot /var/www/domain/public
DirectoryIndex index.php
[...]
</VirtualHost>
As you can see, all the DocumentRoot
are the same.
In theory with the Laravel configuration explained earlier it should work, but in reality account.domain.co, visual.domain.co and domain.co redirect all to the same application instead of their specific Route::group.
Here is the web.php
of my app
Route::get('/', 'IndexController@index')→name('index');
[...]
Route::group([ 'domain' => 'account.domain.com', ],function() {
Route::get('/', 'AccountController@index')→name('account.index');
[...]
});
Route::group([ 'domain' => 'visual.domain.com', ],function() {
Route::get('/', 'VisualController@index')→name('visual.index');
[...]
});
My configuration is: PHP 7.3
, Debian 8 (jessie)
, Apache 2.4.10
and Laravel 5.8
.