我剛開始學習Laravel 5並嘗試創建多語言網站,並且想要爲該語言使用不同的域,因此en.example.app指向英文版,es .example.app到西班牙語等。我使用路由組,下面是我的代碼。Laravel 5,子域路由,帶有可選參數
Route::group(['domain' => '{domain}.example.app'], function() {
Route::get('/', function() {
return view('index');
});
Route::get('test', function(){
return view('index');
});
});
它適用於除example.app以外的所有域。不幸的是,可選參數{domain?}不適用於子域名,我不想重複這樣的路由。
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');
});
});
請問有人請告知如何避免這種重複?
如果用戶訪問example.app什麼語言他得到英文版或自定義網站與不同的顯示 –