Skip to content

Instantly share code, notes, and snippets.

@GhazanfarMir
Last active September 5, 2019 09:45
Show Gist options
  • Save GhazanfarMir/f13173e884c363c3eeff to your computer and use it in GitHub Desktop.
Save GhazanfarMir/f13173e884c363c3eeff to your computer and use it in GitHub Desktop.
Multi site routing in Laraval 5
/*
|--------------------------------------------------------------------------
| Multi Sites Laravel Routing
|--------------------------------------------------------------------------
|
| You may setup single laravel application to serve multiple applications
| hosting on different domains and/or subdomain using the following
| routing feature provided by laravel easily. Just define routes
| as given below.
|
*/
// Match the domain
Route::group(['domain'=> 'laravel.local'], function () {
Route::any('/', function(){
return 'laravel.local';
});
});
// Match the sub domain of the domain
Route::group(['domain'=> '{site1}.laravel.local'], function () {
Route::any('/', function($subdomain){
return 'Sub-Domain: site1.laravel.local:' . $subdomain;
});
});
// Match any other domain
Route::group(['domain'=> '{laravel}.{info1}'], function () {
Route::any('/', function($domain, $tld){
return 'Domain:' . $domain . '.' . $tld;
});
});
// Match sub-domain of any other domain
Route::group(['domain'=> '{site2}.{laravel}.{info}'], function () {
Route::any('/', function($subdomain, $domain, $tld){
return 'Sub-Domain:' . $subdomain . '.' . $domain . '.' . $tld;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment