简体   繁体   English

上传实时服务器后,Laravel 4.2应用程序会发生不必要的重定向

[英]Laravel 4.2 application occurs unnecessary redirection after uploading live server

My laravel(4.2) application is working fine on localhost(xampp). 我的laravel(4.2)应用程序在localhost(xampp)上运行正常。 But after uploading into live server when trying to login, it is showing a blank page with a message saying "redirecting to my home url". 但在尝试登录后上传到实时服务器后,它显示一个空白页面,上面显示“重定向到我的主页”的消息。 It also throws a login error 它还会引发登录错误

Sorry for my weak English. 抱歉我的英语不好。 Please help me. 请帮我。 I am attaching my htaccess below: 我在下面附上我的htaccess:

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

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]

Here is my Controller function. 这是我的控制器功能。

public function adminLoginCheck() {
$validation_rule = array(
    'username' => array('required', 'min:5', 'max:50'),
    'password' => array('required', 'min:6', 'max:50')
);
$validation = Validator::make(Input::all(), $validation_rule);
// Validation Check
if ($validation->fails()) {
    return Redirect::to('/')->withErrors($validation);
} // After Validation Authentication start
else {
    $athentication = Auth::attempt(array('username' => Input :: get('username'), 'password' => Input :: get('password')));
    // When Authentication True
    if ($athentication) { 
        $rememberme = Input::get('remember');
        if(!empty($rememberme)){
            //Remember Login data
           Auth::loginUsingId(Auth::user()->id,true);
        }
        //Redrict to the Target page
        return Redirect::intended('adminDashboard');
    } else {
        //Redrict Login Form with Authentication error massege.
        return Redirect::to('/')->with('authentication_error', 'Username or Password is not valid!');
    }
}

} }

My Auth filter is given below: 我的Auth过滤器如下:

Route::filter('auth', function(){if (Auth::guest()){
if (Request::ajax())
{
    return Response::make('Unauthorized', 401);
}
else
{
    return Redirect::guest('login');
}  }  })

All of the blade templates are available.I am not understanding why the blank page is appearing with the redirecting message.Even when submitting login without inputting 所有的刀片模板都可用。我不明白为什么空白页面会出现重定向消息。即使在没有输入的情况下提交登录信息也是如此

username and password Here is the live url http://noveltyshop.tech-novelty.com/ user:admin pass:pass 用户名和密码这是实时网址http://noveltyshop.tech-novelty.com/ user:admin pass:pass

My route: 我的路线:

Route::get('/', array('as' => 'admin', 'uses' => 'UsersController@adminLoginForm'));
Route::post('/login', array('as' => 'login', 'uses' => 'UsersController@adminLoginCheck'));
Route::get('/adminDashboard', array('as' => 'adminDashboard', 'uses' => 'UsersController@adminDashboard')); 
Route::get('/logout', array('as' => 'logout', 'uses' => 'UsersController@getLogOut')); 
Route::get('/updateUserProfileForm', array('as' => 'updateUserProfileForm', 'uses' => 'UsersController@updateUserProfileForm'));
Route::post('/updateUserProfile', array('as' => 'updateUserProfile', 'uses' => 'UsersController@updateUserProfile')); 

UsersController@adminDashboard UsersController @ adminDashboard

public function adminDashboard() {
    return View::make('admin.pages.admin_dashboard')->with('title', 'AdminDashboard');
}

As you are using Laravel 4.2 当您使用Laravel 4.2时

You shall handle this in your Controller. 您应在控制器中处理此问题。

Here's the default way that we deal with 这是我们处理的默认方式

if (Auth::attempt(['email' => $email, 'password' => $password])) {
    return Redirect::intended('yourTargetPageAfterLogin');
}

In the auth filter you shall have this 在auth过滤器中你应该有这个

Route::filter('auth', function() {
    if (Auth::guest()) {
        return Redirect::guest('login');
    }
});

Note : Make sure you have the blades as you defined in your Controller 注意:确保您拥有控制器中定义的刀片

Suggestion : Why not upgrade to 5.1 ? 建议:为什么不升级5.1

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

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