2013-11-25 197 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