Laravel 4.2 application occurs unnecessary redirection after uploading live server
My laravel(4.2) application is working fine on 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:
<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:
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
My route:
Route::get('/', array('as' => 'admin', 'uses' => '[email protected]'));
Route::post('/login', array('as' => 'login', 'uses' => '[email protected]'));
Route::get('/adminDashboard', array('as' => 'adminDashboard', 'uses' => '[email protected]'));
Route::get('/logout', array('as' => 'logout', 'uses' => '[email protected]'));
Route::get('/updateUserProfileForm', array('as' => 'updateUserProfileForm', 'uses' => '[email protected]'));
Route::post('/updateUserProfile', array('as' => 'updateUserProfile', 'uses' => '[email protected]'));
public function adminDashboard() {
return View::make('admin.pages.admin_dashboard')->with('title', 'AdminDashboard');
}
Answer
As you are using 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
Route::filter('auth', function() {
if (Auth::guest()) {
return Redirect::guest('login');
}
});
Note : Make sure you have the blades as you defined in your Controller
Related Questions
- → .htaccess - not routing to public folder
- → Laravel 4.2 application occurs unnecessary redirection after uploading live server
- → Htaccess negation
- → Building sitemap for 2 wordpress install under 1 domain
- → htaccess not working properly for sub url having more slashes
- → How to give access execute specific php file in server?
- → 301 Redirection from no-www to www in wordpress
- → Cyclical redirection at the start laravel 5 project
- → Can't route in Laravel framework
- → codeigniter seo url with htaccess
- → PHP Seo Friendly URL
- → Convert URL to SEO Friendly
- → IP Canonicalization (WordPress)