Im newbie here.I have a problem with codeigniter segment() method.I referred 6th segment of URL at href($this->url->segment(6)) but when i click the link it goes to full URl/6th segment.i.e I want my link will be go here www.webcoachbd.com(this is 6th segment of my URL) but it goes http://www.example.com/controller_name/method_name/segment1/segment2/segment3/www.webcoachbd.com
3 Answers
Are you doing this in your view?
I dont know if $this->uri->segment will work inside views, never needed it myself.
Instead grab the URI inside your controller and pass it back to the view.
$this->load->view('some view', array(
'link' => $this->uri->segment(6)
));
-
<a href="<?php echo $link;?>">link</a>
Although I dont really understand why you would want to do that.
Comments
From the resulting URL that you posted, it looks like you might be missing a forward slash.
<a href="/<?php echo $this->uri->segment(6); ?>">link text</a>
This would force the URL to forward to the root of your site, rather than to that location inside the current folder that the browser thinks it is in.