我使用Laravel 3兩套登錄控制器 - 主域名進入登錄,所有子域應該途徑門戶/登錄@指數Laravel 3 - 路由集合dyncamically
我使用下面的代碼我routes.php文件:
Route::filter('before', function()
{
$server = explode('.', Request::server('HTTP_HOST'));
if (count($server) == 3)
{
$account = Account::where('subdomain', '=', $server[0])->first();
Session::put('account_id', $account->id);
Route::get('login', '[email protected]');
Route::post('login', '[email protected]');
Route::get('logout/(:any)', '[email protected]');
}
else
{
// some other stuff - no routing calls in here
}
}
此代碼工作正常捕獲子域&做其他任務(如設置$ ACCOUNT_ID),但似乎沒有對路由
test.mydomain影響。 com/login應該去portal/logi n,而是轉到主登錄控制器。
我已經通過搜查,以確保有沒有影響這個過濾器(它是一種遺傳性的應用程序)
這是設置此正確的方式,如果是這樣,還有什麼可以成爲影響呢?
TIA!
謝謝,我會看看。不過,我不相信這是因爲它在count($ server)中;這是因爲它在之前的過濾器中。我將它移動到正常路由並且它正常工作。您的答案似乎基本正確,但 - 我會調查並通知您 – jmadsen
@jmadsen,歡迎您,並等待... –