Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Unable to load static css file

Hi,

I'm not sure there's bb tags for code etc.. so pardon in advance.

My html template:

{# app/views/templates/main.volt #}

<!DOCTYPE html>
<html>
<head>
    <title>{% block title %}{% endblock %}</title>
    <meta charset="utf8">
    <link rel="stylesheet" href="{{ static_url( "public/css/main.css" ) }}">
</head>
<body>
    <div id="content">
        {% block content %}{% endblock %}
    </div>
</body>
</html>

The output is:

<!DOCTYPE html>
<html>
<head>
    <title>My Index Page</title>
    <meta charset="utf8">
    <link rel="stylesheet" href="/catechize/public/css/main.css">
</head>
<body>
    <div id="content">

<h1>Index</h1>

    </div>
</body>
</html>

When I try to load that CSS file, which physically exists, it tries to load a Controller: CatechizeController handler class cannot be loaded

Though my .htaccess in public folder skips real files:

AddDefaultCharset UTF-8

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</IfModule>

Thanks for any help!



34.7k
Accepted
answer

@Boris Lapouga You try replace <link rel="stylesheet" href="{{ staticurl( "public/css/main.css" ) }}"> into {{ stylesheetlink('css/main.css') }}

It doesn't matter.

Even when I try it like that: http://www.catechize.com/catechize/public/css/main.css it tries to load controller.

edited Mar '14

@Boris, pleas try first to call your CSS with plain html, to check if it will work.

in app/views/templates/main.volt:

<link rel="stylesheet" href="css/main.css">

or

<link rel="stylesheet" href="../css/main.css">

{{ stylesheet_link('css/main.css') }} should print out your base URI + css/main.css. Did you set up a base URI in your index.php (can you show your code)?



10.0k

do you set base uri in url service ?