2013-11-25 193 views
1

我試圖將www.example.com/username更改爲username.example.com。我已經建立了Apache,現在我陷入了困境。在我的UserController中我得到了這一點,它的工作罰款www.example.com/username使用laravel的通配符子域名

if($validator->passes() && Auth::attempt($userdata)) { 
    return Redirect::to(Auth::user()->username)->with('flash_notice', 'You have logged in successfully'); 
} 

現在,我得到這個在routes.php文件,但什麼都不做。感謝您的時間。

Route::group(array('domain' => '{account}.example.com'), function() 
{ 

Route::get('{account}', function($account, $id) 
{ 
    $account = Input::get('username'); 
    $id = Input::get('id'); 
}); 

}); 

回答

4

現在您要路由到您的域的根,而不是'{account}'。只需使用一個/作爲路線:

Route::group(array('domain' => '{account}.example.com'), function() 
{ 
    Route::get('/', function() 
    { 
     $account = Input::get('username'); 
     $id = Input::get('id'); 
    }); 
}); 

此外,您重定向需要重定向至子:

return Redirect::to('https://' . Auth::user()->username . '.example.com') 
      ->with('flash_notice', 'You have logged in successfully'); 
+0

還是什麼都沒有.. – phcm

+0

什麼是「一無所有」是什麼意思?你期待它做什麼?你不會從這條路線輸出任何東西! –

+0

嗯,我期待從登錄表單example.com登錄到username.example.com登錄 – phcm