繁体   English   中英

laravel 4.2身份验证在服务器子域上不起作用?

[英]laravel 4.2 auth is not working on server subdomain?

我在Laravel较新。 我已经在本地主机上创建了一个应用程序,并且该应用程序正常运行,但是当我将其上传到子域时,它在身份验证后不会在仪表板上重定向。 我已经阅读了许多教程的解决方案,甚至StackOverflow,但都没有找到任何解决方案。 我已经检查了Laravel日志文件,但是没有日志。 请检查以下代码我的路线。

Route::get('/', function(){ 
if(Auth::check())
    return Redirect::route('dashboard');
else 
    return View::make('login');
});
Route::get('/404',array('before'=>'auth','as'=>'404','uses'=>'HomeController@showFourZeroFour'));
//
Route::get('dashboard',array('before'=>'auth','as'=>'dashboard','uses'=>'HomeController@showWelcome'));

UserController.php用于用户身份验证

 public function login()
 {
    if (Confide::user()) {
        return Redirect::to('/');
    } else {
        return View::make(Config::get('confide::login_form'));
    }
}

/**
 * Attempt to do login
 *
 * @return  Illuminate\Http\Response
 */
public function doLogin()
{
    $repo = App::make('UserRepository');
    $input = Input::all();
    $dt = $input['email'];
    if ($dt == "") {
        $err_msg = Lang::get('confide::confide.alerts.wrong_credentials');
        return Redirect::action('UsersController@login')
            ->withInput(Input::except('password'))
            ->with('error', $err_msg);
    }
    if ($repo->login($input)) {

        $deleted = User::where('email','=',$dt)->first()->deleted;
        $status = User::where('email','=',$dt)->first()->status;

        if ($deleted == '1' || $status == '0') {
            Auth::logout();
            return View::make('login')->with(array('message' => 'Account deactivated/deleted,Contact Admin!','level'=>'error'));
        }

        return Redirect::intended('/');
    } else {
        if ($repo->existsButNotConfirmed($input)) {
            $err_msg = Lang::get('confide::confide.alerts.not_confirmed');
        } else {
            $err_msg = Lang::get('confide::confide.alerts.wrong_credentials');
        }

        return Redirect::action('UsersController@login')
            ->withInput(Input::except('password'))
            ->with('error', $err_msg);
    }
}

和我的.htaccess文件

# Force SSL
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>

# 1 Month for most static assets
<filesMatch ".(css|jpg|jpeg|png|gif|js|ico)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteRule ^(composer|contributing|artisan) - [F,L,NC]

    RewriteEngine On
    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

我已经用.domain.com替换了会话文件中的域密钥

请帮我,我最近两天正在努力。 谢谢

您尚未在路由文件中指定用于认证的路由。 验证路由应如下所示

/**
 * Authentication
 */
Route::controllers([
    'auth' => 'Auth\AuthController',
    'password' => 'Auth\PasswordController',
]);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM