CodeIgniter Forums
Help with different installation folder and paths - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Help with different installation folder and paths (/showthread.php?tid=4223)



Help with different installation folder and paths - El Forum - 11-13-2007

[eluser]guilherme.muller[/eluser]
Hi,
I installed Code Igniter in a subfolder in my site, and I'm having some problems.

The site is at http://www.guilhermemuller.pro.br/sites/diadia/
Here Code Igniter autoloads the Controller "Home". Everything ok so far.

But if I access http://www.guilhermemuller.pro.br/sites/diadia/home/
All of the images and CSS vanish, as if the paths were wrong.
I store the images and css in the folders /diadia/imagens/ and /diadia/css/ , respectively.

And finally, if I access http://www.guilhermemuller.pro.br/sites/diadia/home (without the trailing slash), everything magically appears again...

I couldn't figure out what's happening, looks like Code Igniter is pointing to the wrong "root" of the site, although I configured it in the config and index.php files.

Any ideas?

Thanks in advance!


Help with different installation folder and paths - El Forum - 11-13-2007

[eluser]gtech[/eluser]
hummpphh whats your base_url set to in your config.php?


Help with different installation folder and paths - El Forum - 11-13-2007

[eluser]guilherme.muller[/eluser]
Yes, I set it to http://www.guilhermemuller.pro.br/sites/diadia/


Help with different installation folder and paths - El Forum - 11-14-2007

[eluser]esra[/eluser]
Using absolute urls is the best solution. Load the url helper in your controller or autoload the url helper. Then use the base_url() function in your url paths as in <?php echo base_url();?>diadia/imagens/ and <?php echo base_url();?>diadia/css/. I'm assuming that index.php is in diadia/. If short tags are enabled in php.ini or if you force short tags on in confg.php, you can use <?=base_url();?> rather than <?php echo base_url();?>.


Help with different installation folder and paths - El Forum - 11-14-2007

[eluser]guilherme.muller[/eluser]
Thanks for the reply!
Well, I am aware of that use of the url helper, and it is a solution, but I was trying to find other way around. This is because writing a php tag before every css, img or script tag is not what I wanted to do...

Maybe if Code Igniter could set the BASEPATH ou other constant to the right value, I don't know.


Help with different installation folder and paths - El Forum - 11-14-2007

[eluser]esra[/eluser]
If base_url in config.php is set to http://www.guilhermemuller.pro.br/sites/diadia/, then you should be able to use relative paths in relation to the directory where index.php resides.


Help with different installation folder and paths - El Forum - 11-15-2007

[eluser]guilherme.muller[/eluser]
I set it to http://www.guilhermemuller.pro.br/sites/diadia/, but it doesn't seem to work... If I can't find a solution I'll use the absolute paths like you mentioned.

Thanks for the help