1

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

0

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

Its not url but uri

$this->uri->segment(6);

and i think you are missing = operator in the anchor

<a href="<?=$this->uri->segment(6)?>">MyLink</a>

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.