1

The CSS code in my <CI root>/css/menus.css is not applied. The file is displayed without CSS.

Here is my header template:

<html>
    <head>
        <title>air de java</title>
        <link rel = "stylesheet" type = "text/css" 
        href = "<?= base_url('css/menus.css'); ?>" media="all">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <h1>AIR DE JAVA</h1>
        ...

When I replace the PHP call in href attribute with "http://localhost/fil/index.html" I get a 404 error (index.html is a dummy file with a h1 tag).

I have installed the url plugin. In my controller, I have:

$this->load->helper('url');

The base_url() function returns the expected URL ("http://localhost/fil/css/menus.css")

It could worth notice that I am using XAMPP on Windows, and here is the redirection part of my httpd.conf:

<Directory "C:/Users/lolve/Dropbox/air de java/air_de_java_appliperso2">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks Includes ExecCGI

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All

#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>

And the alias:

ScriptAlias /fil/ "C:/Users/lolve/Dropbox/air de java/air_de_java_appliperso2/"

I spent time on searching on the net but without success.

EDIT:

CodeIgniter has a strange behaviour: it seems to head to old versions of my files. I saw it because the click on a button calls a Javascript function, whose an old version contained this line alert("enable"); and now I no more have this line, but the button is still there, and click on it triggers the chrome's notification ... Very strange. I tried to hit CTRL+F5 to bypass chrome's cache, but without success. From explorer is the same: the problem comes from CodeIgniter. But why? Also, Chrome's debugger pointed out the fact that there is an error with the load of menus.css: plz have a look at this

EDIT

I had a look at Apache logs, and here is what I found:

[Sat Feb 23 18:58:59.817271 2019] [win32:error] [pid 13940:tid 1900] [client ::1:50408] AH02102: C:/Users/lolve/Dropbox/air de java/air_de_java_appliperso2/css/menus.css is not executable; ensure interpreted scripts have "#!" or "'!" first line, referer: http://localhost/fil/ [Sat Feb 23 18:58:59.817271 2019] [cgi:error] [pid 13940:tid 1900] (9)Bad file descriptor: [client ::1:50408] AH01222: don't know how to spawn child process: C:/Users/lolve/Dropbox/air de java/air_de_java_appliperso2/css/menus.css, referer: http://localhost/fil/

9
  • "when I replace the php call in href attribute with "localhost/fil/index.html" I get a 404 error. (index.html is a dummy file with a h1 tag)" ... What do you mean by that? Commented Feb 23, 2019 at 8:56
  • sorry, it wasn't totally true: in my browser, if I try to access to "localhost/fil/css/menus.css " I get an error 500 and independently of this, if I try to replace in my header.php file the href (with php call) by href='localhost/fil/css/menus.css' nothing happens, I get the page without css applied. now it should be clearer. Commented Feb 23, 2019 at 9:26
  • Okay. So checking through your folder structure, where exactly do you have your menus.css saved? Commented Feb 23, 2019 at 10:37
  • it's in the <root>/css folder, root being the directory containing the codeigniter's application and system directories Commented Feb 23, 2019 at 10:40
  • Okay. From your XAMPP's httpd.conf file, what value do you have for DocumentRoot ? Commented Feb 23, 2019 at 10:57

1 Answer 1

1

You have not mentioned why you are using that ScriptAlias, but that is the problem. The Apache log record you quote shows:

... menus.css is not executable; ... referer: http://localhost/fil/

So you visited http://localhost/fil/, and Apache tried to execute your CSS, which of course makes no sense. Why is Apache trying to do that? Because of this:

ScriptAlias /fil/ "C:/Users/lolve/Dropbox/air de java/air_de_java_appliperso2/"

According to the Apache documentation for ScriptAlias:

The ScriptAlias directive has the additional effect of marking the target directory as containing only CGI scripts.

So Apache thinks that anything inside the fil/ directory is an executable CGI script. When you try to access fil/css/menus.css, Apache thinks it is some kind of CGI script, and tries to execute it. That won't work - Apache should just send that file as text to the browser, which can parse it and use it to style the page.

Do you have some specific reason to use that ScriptAlias? You should not need it for a normal Codeigniter installation, you'd only use that for some specific (and not very usual) requirement. Get rid of it if you can, and restart Apache. If you do need it, you'll need to change the directory it points at to get Codeigniter to work.

Sign up to request clarification or add additional context in comments.

1 Comment

thank you, I found this answer yesterday and was ready to write it now but you were quicker. thank you anyway!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.