Reputation: 265
I am trying to open a page on clicking on a link in my codeigniter application. This is the snippet of my attempt
at the controller level this is snippet
//load return policy
function returnpolicy()
{
$this->load->view("return_policy");
}
at the view level this is the snippet
<div class="toggle">
<a href="<?php echo site_url()."/"."gotopolicy/returnpolicy" ?>" class="toggle-title">Return Policy</a>
</div>
on clicking on the link it does not navigate to the page. please what am I missing. am new to codeigniter
Upvotes: 1
Views: 1729
Reputation: 461
try to remove class="toggle-title"
or try this
<div >
<a href="<?=base_url()?>/Gotopolicy/returnpolicy">Return Policy</a>
</div>
Upvotes: 0
Reputation: 16997
You should understand the difference between site_url
and base_url
first
echo base_url(); // http://example.com/website
echo site_url(); // http://example.com/website/index.php
You can rewrite it as follows :
<?php echo site_url('controller/method');?>
In HMVC
<?php echo site_url('module/controller/method');?>
So in your case
<a href="<?php echo site_url('gotopolicy/returnpolicy');?>" class="toggle-title">Return Policy</a>
you can use the URL
helper this way to generate an <a>
tag
anchor(uri segments, text, attributes)
So... to use it...
<?php echo anchor('gotopolicy/returnpolicy', 'Return Policy', 'class="toggle-title"') ?>
Possible issue could be of htaccess,
create a file .htaccess
in your root CI folder
and add below contents to it
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Make $config['index_page'] = "";
Upvotes: 1