I am Working On Codeigniter 4, I Have Face a problem when I am click menu Url are change
my controller is
<?php namespace App\Controllers;
class Pages extends BaseController
{
public function index($page='Home')
{
if(!is_file(APPPATH.'/views/pages/'.$page.'.php')){
die;
throw new \CodeIgniter\Exceptions\PageNotFoundException($page);
}
return view("pages/{$page}");
}
public function about($page='About')
{
if(!is_file(APPPATH.'/views/pages/'.$page.'.php')){
die;
throw new \CodeIgniter\Exceptions\PageNotFoundException($page);
}
return view("pages/{$page}");
}
public function contact($page='Contact')
{
if(!is_file(APPPATH.'/views/pages/'.$page.'.php')){
die;
throw new \CodeIgniter\Exceptions\PageNotFoundException($page);
}
return view("pages/{$page}");
}
}
My Route page
$routes->get(':/', 'Pages::index');
$routes->get(':/', 'Pages::about');
$routes->get(':/', 'Pages::contact');
and html is
<ul class="nav navbar-nav">
<li class="active"><a href="pages/">Home</a></li>
<li><a href="pages/about">About</a></li>
<li><a href="pages/contact">Contact</a></li>
</ul>
initialy it will work fine but when i am click again in menu its url change http://localhost/pages/contact to like this url http://localhost/pages/pages/contact i dont know where am i wrong please suggest me
change to absolute path
<ul class="nav navbar-nav">
<li class="active"><a href="/pages/">Home</a></li>
<li><a href="/pages/about">About</a></li>
<li><a href="/pages/contact">Contact</a></li>
</ul>