![]() |
index.php - works - index.php/home - does not - Please help explain - 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: index.php - works - index.php/home - does not - Please help explain (/showthread.php?tid=8894) |
index.php - works - index.php/home - does not - Please help explain - El Forum - 06-04-2008 [eluser]ICEcoffee[/eluser] Hi Folks I have on my local server a directory called ci2. I have setup a default controller called home.php. I have in my config file: Code: $config['base_url'] = "http://127.0.0.1/ci2/"; My default controller (home) is this: Code: <?php My View file mentions in the above code is this (head section only): Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> The problem? if I type into my browser: http://localhost/ci2/ or http://localhost/ci2/index.php, I see the referenced stylesheet. If I type: http://localhost/ci2/index.php/home/ I DO NOT SEE THE STYLESHEET. Can someone explain what is happening. Thank you. index.php - works - index.php/home - does not - Please help explain - El Forum - 06-04-2008 [eluser]stuffradio[/eluser] I'm not too sure right now, but you have a space after $data['name'] = "brian" ; Try removing that. index.php - works - index.php/home - does not - Please help explain - El Forum - 06-04-2008 [eluser]Merolen[/eluser] Doesn't the base_url have to be there? I you don't specify it it is relative to the URL you see in your URL field. Code: <link rel='stylesheet' href="<?=base_url()?>styles/style.css" type='text/css' media='screen' charset='utf-8' /> index.php - works - index.php/home - does not - Please help explain - El Forum - 06-04-2008 [eluser]Brandon Dickson[/eluser] Merolen's correct, CI uses url routing to make things cleaner, but to your web browser, when you type in: http://localhost/ci2/index.php/home/ the browser assumes that "home" is a directory, so its looking for you css file here: http://localhost/ci2/index.php/home/styles/style.css try using site_url('styles/style.css') or base_url() as Merolen described. -Brandon index.php - works - index.php/home - does not - Please help explain - El Forum - 06-05-2008 [eluser]ICEcoffee[/eluser] The previous two posts sounds 'bang on the money'. It's seems the 'logical' action to use. I don't know why I didn't think of it. :red: Thanks guys, I'll give that a go later. |