I’ve just started learning Laravel 5 and trying to create multilanguage web site and want to use different domains for the language so en.example.app points to English version, es.example.app to Spanish and so on. I use route groups and below is my code.
Route::group(['domain' => '{domain}.example.app'], function() {
Route::get('/', function () {
return view('index');
});
Route::get('test', function(){
return view('index');
});
});
It works fine for all domains except example.app. Unfortunately optional parameters {domain?} doesn’t work for subdomains, and I don’t want to duplicate routes like this.
Route::get('/', function () {
return view('index');
});
Route::get('test', function(){
return view('index');
});
Route::group(['domain' => '{domain}.example.app'], function() {
Route::get('/', function () {
return view('index');
});
Route::get('test', function(){
return view('index');
});
});
Could somebody please advise how to avoid this duplication?