【问题标题】:symfony2 http 403 error (access denied) for CSS fileCSS文件的symfony2 http 403错误(拒绝访问)
【发布时间】:2013-07-02 19:26:16
【问题描述】:

我的情况很奇怪,一个我的 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>

我的文件结构:

我已经成功运行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>

谁能给点建议?

谢谢

【问题讨论】:

    标签: css symfony twig assetic


    【解决方案1】:

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

    &lt;link href="{{ asset('css/Aristo/Aristo.css') }}" rel="stylesheet" type="text/css" /&gt;

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

    希望对你有帮助

    最好的尊重

    【讨论】:

    • 同样的问题...顺便说一句,当我在 firebug 中检查 URL 时,正确,但我收到 HTTP 403 错误
    • 另外.. 只有一个文件会发生这种情况是否有意义?
    • 您可以编辑您的消息并发布 403 错误消息吗?谢谢
    • 用服务器响应编辑了我的问题
    • 你检查文件权限了吗? symfony.com/doc/current/book/…
    猜你喜欢
    • 1970-01-01
    • 2018-01-18
    • 2015-12-03
    • 1970-01-01
    • 2015-12-05
    • 2020-01-25
    • 2014-11-26
    • 2021-12-13
    • 2015-09-07
    相关资源
    最近更新 更多