简体   繁体   中英

symfony2 http 403 error (access denied) for CSS file

I have a very weird situation, one of my CSS files is not able to load, I see HTTP 403 error in firebug.

My twig:

<head>
    {% block head %}
        <script type="text/javascript" src="/bundles/my/js/jquery.min.js"></script>
        <script type="text/javascript" src="/bundles/my/js/jquery-ui.min.js</script>       
        <link rel="stylesheet" href="/bundles/my/css/Aristo/Aristo.css" />
        <link rel="stylesheet" href="/bundles/my/css/style.css" />
        {% endblock %}
</head>

My files structure:

在此处输入图片说明

I've run php app/console assets:install web --symlink successfully

app/console assetic:dump returns:

Dumping all dev assets.
Debug mode is on.

Note: js/jquery.min.js, js/jquery-ui.min.js and css/style.css loads fine, only Aristo/Aristo.css yells HTTP 403 error

Edit GET http://my.local/bundles/my/css/Aristo/Aristo.css Response message:

Response Header

HTTP/1.1 403 Forbidden
Date: Thu, 04 Jul 2013 18:28:36 GMT
Server: Apache/2.2.22 (Ubuntu)
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 260
Keep-Alive: timeout=5, max=97
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1

Response HTML:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /bundles/my/css/Aristo/Aristo.css
on this server.</p>
<hr>
<address>Apache/2.2.22 (Ubuntu) Server at my.local Port 80</address>
</body></html>

Can anyone advise?

Thanks

You may use asset instead of direct path to your ressources :

<link href="{{ asset('css/Aristo/Aristo.css') }}" rel="stylesheet" type="text/css" />

see: http://symfony.com/doc/current/book/templating.html#linking-to-assets

Hope it's helpful

Best regard

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM