views:

39

answers:

2

I am using the CodeIgniter framework to work on my latest website. In my views, I am trying to load graphics from another folder, external of the CodeIgniter installation.

However, CodeIgniter is rewriting the links when I use absolute links to the resources.

Is there a way I can configure it to allow absolute links, rather than re-writing them?

A: 

What code are you using to output the links?

Codeigniter shouldn't be messing with absolute links, infact it will only mess with it if you pass it through site_url() or similar.

Will
I'm just writing the links directly inside of a view.
samoz
As in <img src="http://www.domain.tld/graphics/image.png" /> or <a href="http://www.domain.tld/graphics/image.png">link</a> ? As long as it doesn't go through a CI function CI won't touch it. Basic question, but always worth asking, you're not missing the http:// are you? Could it be a .htaccess issue?
Will
+2  A: 

I think you probably need to use the URL helper function base_url()

Like so:

<img src="<?php echo base_url()?>directory/images/graphic.png" />

This example assumes the directory is in the root of your public_html, and that $config['base_url'] is set correctly in application/config/config.php.

$config['base_url'] = "http://dev.testing.com/site/";

You also need to load the URL Helper in your controlling class.

Like so

 class MyClass extends Controller{

 function MyClass()
 { 
  parent::Controller();
  $this->load->helper('url');
 }

 }

If your still having problems, go back into application/config/config.php and try changing:

$config['uri_protocol'] = "AUTO";

To:

$config['uri_protocol'] = "REQUEST_URI";
DRL
That looks like the more 'CI' way to do links anyways. Thanks!
samoz