No one replied or liked this question on Laracasts.com for last 7 years that's why I do not like this platform.
Aug 9, 2018
3
Level 1
Shared hosting redirect to public always
Options -MultiViews -Indexes
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
above is my public directory .htaccess file.
========================================================== below is my root directory .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
but still, it redirects to public/dashboard
below is my login method
public function login(Request $request)
{
$this->validateLogin($request);
try{
if (Auth::attempt(['email' => request('email'), 'password' => request('password'), 'status' => 'active', 'user_type' => '...'])) {
// Authentication passed...
return redirect()->intended('dashboard');
}
elseif (Auth::attempt(['email' => request('email'), 'password' => request('password'), 'status' => 'active', 'user_type' => '...'])) {
// Authentication passed...
return redirect()->intended('/dashboard/blog');
}
elseif (Auth::attempt(['email' => request('email'), 'password' => request('password'), 'status' => 'active', 'user_type' => '...'])) {
// Authentication passed...
return redirect()->intended('/admin');
}
else{
return redirect()->back()->withErrors('Unauthorized user');
}
}catch(\Exception $e){
return redirect()->back()->withErrors($e->getMessage());
}
}
other login works fine but when the first condition checked it redirects to public/dashboard
Please or to participate in this conversation.