![]() |
base_url() and url helper - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: base_url() and url helper (/showthread.php?tid=28033) Pages:
1
2
|
base_url() and url helper - El Forum - 02-27-2010 [eluser]elaniobro[/eluser] Having issues with the config.php file and setting the base URL. I currently have my config.php file setting my base pat as follows: Code: $config['base_url'] = "http://localhost:8888/www.example.com/com/5/system/application"; However when I use the url helper anchor(): Code: <?= anchor('/thoughts/more/'.$row->id, 'read');?> I get a 404: The requested URL /www.example.com/com/5/system/application/index.php/thoughts/more/2 was not found on this server. However, if I change the config to the following: Code: $config['base_url'] = "http://localhost:8888/www.example.com/com/5 Removing '/system/application' from the end of the base URL, the anchor() works properly, but no images/css/js etc.. works. Any ideas? base_url() and url helper - El Forum - 02-27-2010 [eluser]jedd[/eluser] [quote author="elaniobro" date="1267326365"]Having issues with the config.php file and setting the base URL. I currently have my config.php file setting my base pat as follows: Code: $config['base_url'] = "http://localhost:8888/www.example.com/com/5/system/application"; In my copy of CI, the config.php includes a comment just above the $config['base_url'] section that reads: Code: | URL to your CodeIgniter root. Typically this will be your base URL, Is yours different? base_url() and url helper - El Forum - 02-27-2010 [eluser]elaniobro[/eluser] In my copy of CI, the config.php includes a comment just above the $config['base_url'] section that reads: Code: | URL to your CodeIgniter root. Typically this will be your base URL, Is yours different?[/quote] No, mine is the same. Perhaps my folder structure is not set up correctly. I have my site living here: system/application/mysite Is this not correct? Should it be moved? maybe that would alleivate the issues I am having. base_url() and url helper - El Forum - 02-27-2010 [eluser]jedd[/eluser] [quote author="elaniobro" date="1267326365"] Removing '/system/application' from the end of the base URL, the anchor() works properly, but no images/css/js etc.. works. [/quote] You might want to show: a) your code for pulling in images (are you using img() for example?) b) your code for pulling in css and js etc (are you using link_tag() for example?) c) the web-browser's page source for these same sections d) your .htaccess file The section in the wiki on [url="/wiki/How_to_ask_a_good_question/"]how to ask a good question[/url] covers some of the kinds of information that's handy to provide with this sort of problem. The [url="/wiki/FAQ"]FAQ[/url] (also in the wiki) is a good thing to read through first to see if a question has already been answered. base_url() and url helper - El Forum - 02-27-2010 [eluser]jedd[/eluser] If yours is the same, why don't you use a trailing slash on your base_url then? base_url() and url helper - El Forum - 02-27-2010 [eluser]jedd[/eluser] To spell it out, you almost definitely want this: Code: $config['base_url'] = "http://localhost:8888/www.example.com/com/5/"; (Judging from what you've revealed so far.) My earlier observations (regarding other info to show us) still stand. base_url() and url helper - El Forum - 02-27-2010 [eluser]elaniobro[/eluser] [quote author="jedd" date="1267337753"]To spell it out, you almost definitely want this: Code: $config['base_url'] = "http://localhost:8888/www.example.com/com/5/"; (Judging from what you've revealed so far.) My earlier observations (regarding other info to show us) still stand.[/quote] a) your code for pulling in images (are you using img() for example?) no I am using: Code: <img src="<?= base_url();?>img/logo_tagline.png"/> <!-- for example --> Code: <link type="text/css" href="<?= base_url();?>com/css/global.css" rel="stylesheet" media="screen" /> You want a link to my actual site? d) your .htaccess file non existent at the moment. Hope those answers gives you more insight. I am new to CI, and have read through the wiki, but will most certainly go back and comb through it again. I appreciated your help thus far. I might add that I am using MAMP for local dev. base_url() and url helper - El Forum - 02-27-2010 [eluser]elaniobro[/eluser] LIVE Code: $config['base_url'] = "http://www.example.com/5/system/application"; MAMP Code: $config['base_url'] = "http://localhost:8888/www.example.com/com/5/system/application"; base_url() and url helper - El Forum - 02-27-2010 [eluser]jedd[/eluser] [quote author="elaniobro" date="1267338545"]LIVE Code: $config['base_url'] = "http://www.example.com/5/system/application"; Don't do that. Do this instead (as I've already suggested) Code: $config['base_url'] = "http://www.example.com/5/"; [quote author="elaniobro" date="1267338545"] [/code] <img src="<?= base_url();?>img/logo_tagline.png"/> [/code] [/quote] Don't do that. Do this instead Code: img('img/logo_tagline.png'); Have a play with it - taking note of your page-source in your browser - and see how you go. You can also look at your web server (apache) access and error logs, to see what files (say logo_tagline.png) it's trying to find, and where it's looking for it in the file system - this is often very instructive in these kinds of cases. base_url() and url helper - El Forum - 02-27-2010 [eluser]elaniobro[/eluser] -Jedd Thanks, I will certainly give it ago. As for the img(); does that need to have a helper loaded, or is that built in to the core? Also what is the benefit of using img(); vs base_url() within the <img> tag? |