我读了很多关于这个问题的帖子,但是在我的项目中无法解决。
基本上,我有一个Symfony2项目,其中包括Twitter Bootstrap(v3)。 开发模式下一切正常,但是当我尝试在生产模式下运行时,出现错误,说找不到Twitter Bootstrap字体:
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/Symfony/css/fonts/glyphicons-halflings-regular.woff
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/Symfony/css/fonts/glyphicons-halflings-regular.ttf
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/Symfony/css/fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular
由于Symfony中没有css/文件夹,这种情况是正常的。
以下是该项目的结构:
app/
src/
vendor/
web/
css/
compiled/
fonts/
js/
Twig文件:
{% block stylesheets %}
{% stylesheets output="css/compiled/main.css" filter='cssrewrite'
'css/bootstrap.min.css'
'css/general.css'
'css/navigation.css'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% endblock %}
我使用了:
php app/console assetic:dump --env=prod
我已经检查了bootstrap.min.css(在web / css / compiled中的prod和dev文件)并且它们都具有相同的字体路径。类似于(../../../ fonts / fontName.ext)。
如果我们看一下路径,无论是在dev模式还是prod模式下,它都不应该起作用,因为路径将fonts /文件放在web目录之外。然而,在dev模式下它能够正常工作。
你有任何解决方法吗?
我会很感激的。