Problems with $config['base_url'] |
[eluser]bjuneau[/eluser]
Hello, I noticed today that if I visit http://www.mysite.com/ some JS files aren't found using: Code: <?php echo base_url(); ?>dir/dir/something.js However, if I switch to http://mysite.com/ it works just fine. Code: // config.php Code: // autoload.php I host with MediaTemple and use their Grid package... Thanks in advance!
[eluser]bjuneau[/eluser]
This fixed it: Code: // constants.php Code: src="<?php echo BASE_URI; ?>dir/dir/something.js"
[eluser]Aken[/eluser]
I doubt that has anything to do with the base_url() helper. Check your .htaccess file or something.
[eluser]boltsabre[/eluser]
And you're "double declaring" a variable. Code: $base_uri = $_SERVER['SCRIPT_NAME']; can be replaced with Code: $base_uri = str_replace('index.php', '', $_SERVER['SCRIPT_NAME']); Not a problem with how you have done it and it's completely unrelated to your question, this is merely a "coding tip". Less code, less chance for bugs.
[eluser]InsiteFX[/eluser]
It should be like this. Code: <?php echo base_url('dir/dir/something.js'); ?> |
Welcome Guest, Not a member yet? Register Sign In |