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?
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";
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.
精彩评论