I was just starting to learn Laravel 5 and was trying to create a multilingual website and want to use different domains for the language, so en.example.app points to the English version, es.example.app to Spanish, etc. 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 great for all domains except example.app. Unfortunately, the optional parameters {domain?} Do not work for subdomains, and I do not 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'); }); });
Can someone please advise how to avoid this duplication?
Teymur
source share