CSS文件的symfony2 http 403错误(访问被拒绝)

时间:2013-07-04 18:17:16

标签: css symfony twig assetic

我有一个非常奇怪的情况,一个我的CSS文件无法加载,我在firebug中看到HTTP 403错误。

我的树枝:

<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>

我的文件结构:

enter image description here

我已成功运行php app/console assets:install web --symlink

app/console assetic:dump返回:

Dumping all dev assets.
Debug mode is on.

注意: js / jquery.min.js,js / jquery-ui.min.js和css / style.css加载正常,只有Aristo / Aristo.css大喊HTTP 403错误

修改 获取http://my.local/bundles/my/css/Aristo/Aristo.css 回复信息:

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

回复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>

有人可以提供建议吗?

由于

1 个答案:

答案 0 :(得分:1)

您可以使用asset代替您的资源的直接路径:

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

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

希望它有用

最好的关注