Hi,
I need some help in formatting URLs. whenever I am redirecting to a specific link "index.php" ("http://localhost/
index.php/login") appears in the URL and as a result, my CSS does not load. Below are the routes that I have created and the filter that redirects the users to the login link.
Code:
//// Routes ////
$routes->get('/', 'AdminPanel::index', ['filter' => 'authGuard']);
$routes->get('login', 'Login::index');
$routes->post('loginvalidate', 'Login::validateLogin');
$routes->get('logout', 'Login::logout');
//// Filter ////
<?php
namespace App\Filters;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Filters\FilterInterface;
class AuthGuard implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null)
{
if (!session()->get('isLoggedIn'))
{
return redirect()
->to('/login');
}
}
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
}
}