Problems using base_url - 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: Problems using base_url (/showthread.php?tid=18486) Pages:
1
2
|
Problems using base_url - El Forum - 05-07-2009 [eluser]skoots[/eluser] Newbie here. I've set my base_url (in the config file)to Code: http://localhost.test/ but whenever I echo Code: base_url() Code: http://localhost.test/index.php//http//localhost.test/ I'm not using an .htaccess file. Is this something I can fix in the CI setup or am I having a server problem? Any help would be appreciated. Problems using base_url - El Forum - 05-07-2009 [eluser]Thorpe Obazee[/eluser] if you want to link using an anchor then use anchor() Code: anchor() Problems using base_url - El Forum - 05-07-2009 [eluser]skoots[/eluser] Thanks for the reply. Using Code: anchor() For example if I try to link to a stylesheet: Code: <link rel='stylesheet' href='<?=base_url()?>static/css/stylesheet.css' type='text/css' /> The resulting url is: Code: http://localhost.test/index.php//http//localhost.test/static/css/stylesheet.css ...which obviously wont work. Any ideas? Problems using base_url - El Forum - 05-07-2009 [eluser]Thorpe Obazee[/eluser] what happens when you echo base_url() ? Problems using base_url - El Forum - 05-07-2009 [eluser]skoots[/eluser] Frustratingly enough it's the correct url: Code: http//localhost.test/ But it doesn't work with the stylesheet link or if I use it like this: Code: <a ><?php base_url($nav['path'])?>Link</a> The above results in a link that directs to: Code: http://localhost.test/index.php/http//localhost.test/(..etc) So it echos properly in the code, but the links don't work (particularly with the stylesheet) Might be an Apache thing... Problems using base_url - El Forum - 05-07-2009 [eluser]Thorpe Obazee[/eluser] [quote author="skoots" date="1241774542"] Code: <a ><?php base_url($nav['path'])?>Link</a> I honestly doubt that this thing works though. I tried to make my url like yours and it's working just fine. Problems using base_url - El Forum - 05-07-2009 [eluser]skoots[/eluser] Typo in the above code. But take the href for the stylesheet: Code: <link rel='stylesheet' href='<?=base_url()?>static/css/stylesheet.css' type='text/css' /> When I look at the source code through the browser I get: Code: <link rel='stylesheet' href='http//localhost.test/static/css/stylesheet.css' type='text/css' /> But that href tries to load the stylesheet from http://localhost.test/index.php/http//localhost.test/static/css/stylesheet.css - somehow Code: http://localhost.test/index.php Problems using base_url - El Forum - 05-07-2009 [eluser]skoots[/eluser] bargainph thanks for your replies I think I'll move on here - it's a small site so I'll hard code the links and I'll see if the problem is resolved when it's on a different server. Seems like it may be a problem with my Apache setup. thanks again. Problems using base_url - El Forum - 05-07-2009 [eluser]Thorpe Obazee[/eluser] It probably is a server side problem. Good luck Problems using base_url - El Forum - 05-07-2009 [eluser]xwero[/eluser] skoots whate are your base_url and index settings in the config.php file |