Php 使用laravel的通配符子域

Php 使用laravel的通配符子域,php,laravel,laravel-4,Php,Laravel,Laravel 4,我正在尝试将www.example.com/username更改为username.example.com。我已经安装了Apache,现在我被困在这里。在我的userController中,我得到了这个,它在www.example.com/username上运行良好 if($validator->passes() && Auth::attempt($userdata)) { return Redirect::to(Auth::user()->username)

我正在尝试将www.example.com/username更改为username.example.com。我已经安装了Apache,现在我被困在这里。在我的userController中,我得到了这个,它在www.example.com/username上运行良好

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');
});

});

您现在希望路由到域的根目录,而不是
'{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');

您现在希望路由到域的根目录,而不是
'{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');

“没有”是什么意思?你期望它做什么?你不能从那条路线输出任何东西!我希望能从example.com/login的登录表单中找到username.example.com“nothing”是什么意思?你期望它做什么?你不能从那条路线输出任何东西!我希望能从example.com/login的登录表单中找到username.example.com