musicvicious
musicvicious

Reputation: 1093

CodeIgniter - adds an extra class to my URL when i click on a link

I'm new in CI as well in php. I have a problem that's bugging me for two days now:

when i click on a link in my admin header(say: Articles) it takes me to: www.example.com/admin/articles, which is ok. If now i try to click on another link in the header (say: Add articles), the url becomes: www.example.com/admin/admin/add_articles - it adds an extra admin to my url. if i click again on Articles, the url will be: www.example.com/admin/admin/admin/articles, and so on.

Do you have any idea why is this happening? Thanks

Upvotes: 0

Views: 172

Answers (3)

Dan F.
Dan F.

Reputation: 1363

Don't use

$config['base_url] . 'controller/action',

use the function:

site_url('controller/action');

Or use the anchor function @András Rátz suggested.

Upvotes: 0

ghostika
ghostika

Reputation: 1503

You have 2 choice, the first is that you wrote in every link base_url() OR you can use a built in helper:

anchor('route','label','attributes')

in your example:

anchor('admin/add_article','Add an article',array('class' => 'link'))

Then that will create this HTML code:

<a href="what is your base_url value/admin/add_article" class="link">Add an article</a>

Upvotes: 2

Waqar Alamgir
Waqar Alamgir

Reputation: 9978

use absolute urls not relative, use $config['base_url'] before every link

Upvotes: 0

Related Questions