Welcome Guest, Not a member yet? Register   Sign In
index.php - works - index.php/home - does not - Please help explain

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:

$config['base_url'] = "";
$config['index_page'] = "index.php";

My default controller (home) is this:
class Home extends Controller
    public $data;
    public function _Constructor()
        // initiators
    public function index()
        // get data from database
        $data['name'] = "brian" ;
        $this->load->view('home_view', $data);

My View file mentions in the above code is this (head section only):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
       &lt;title&gt;&lt;? echo $meta_title; ?&gt;&lt;/title&gt;
         &lt;? echo $config['style_main']; ?&gt;
         &lt;link rel='stylesheet' href='styles/style.css' type='text/css' media='screen' charset='utf-8' /&gt;
         &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
        &lt;link rel="shortcut icon" href="../favicon.ico" /&gt;

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.

I'm not too sure right now, but you have a space after $data['name'] = "brian" ;

Try removing that.

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.

&lt;link rel='stylesheet' href="&lt;?=base_url()?&gt;styles/style.css" type='text/css' media='screen' charset='utf-8' /&gt;

[eluser]Brandon Dickson[/eluser]
Merolen's correct, CI uses url routing to make things cleaner, but to your web browser, when you type in:


the browser assumes that "home" is a directory, so its looking for you css file here:


try using site_url('styles/style.css') or base_url() as Merolen described.


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.

Theme © iAndrew 2016 - Forum software by © MyBB