【发布时间】:2014-12-21 11:52:48
【问题描述】:
我正在开发一个带有管理子域的应用程序,所以我有admin.example.com 和www.example.com。我的问题是:每当用户尝试输入admin.example.com 时,他都应该被重定向到登录页面(如果未登录),该页面位于www.example.com/login 中
如何从admin.example.com 重定向到www.example.com/login ?我已经在我的app/routes.php 中尝试过这个:
Route::group(['domain' => 'admin.example.com'], function(){
Route::get('/', 'AdminHomeController@getWelcome');
Route::any("{all}", function(){App::abort(404);})->where('all', '.*');
// I used this line to block access routes in admin.example.com not defined here
});
Route::group(['domain' => 'www.example.com'], function()
{
.....
Route::controller('/', 'AuthController'); // here is defined getLogin
}
使用此代码,我可以执行Redirect::to(action('AuthController@getLogin'))。虽然我不确定这是实现这一目标的正确方法。有什么建议吗?
【问题讨论】:
标签: redirect laravel-4 laravel-routing