Help with different installation folder and paths |
[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!
[eluser]gtech[/eluser]
hummpphh whats your base_url set to in your config.php?
[eluser]guilherme.muller[/eluser]
Yes, I set it to http://www.guilhermemuller.pro.br/sites/diadia/
[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();?>.
[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.
[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.
[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 |
Welcome Guest, Not a member yet? Register Sign In |