2

我在 Symfony 2.2 中有两个捆绑包

1. domaint.tld 上的 FrontBundle

  • domain.tld/symfony/src/Company/FrontBundle/Resources/public/css
  • domain.tld/symfony/src/Company/FrontBundle/Resources/public/images
  • domain.tld/symfony/src/Company/FrontBundle/Resources/public/js

2. admin.domain.tld 上的 AdminBundle

  • domain.tld/symfony/src/Company/AdminBundle/Resources/public/css (custom.css)
  • domain.tld/symfony/src/Comapny/AdminBundle/Resources/public/images (image.png)
  • domain.tld/symfony/src/Company/AdminBundle/Resources/public/js

domain.tld/symfony/src/Comapny/AdminBundle/Resources/public/css/custom.css

div.image {
    background-image: url(../images/image.png);
}

domain.tld/symfony/app/config/config.yml

debug:          "%kernel.debug%"
use_controller: false
bundles:        [ AdminBundle, FrontBundle ]
read_from:      "%kernel.root_dir%/../../public_html/"
write_to:      "%kernel.root_dir%/../../public_html/"
filters:
    cssrewrite: ~

domain.tld/symfony/app/config/routing.yml

admin:
    host: "admin.domaint.tld"
    resource: "@AdminBundle/Controller/"
    type:     annotation

front: 
    host: "domain.tld"
    resource: "@FrontBundle/Controller/"
    type:     annotation

domain.tld/symfony/src/Company/AdminBundle/Resources/views/layout.html.twig

{% stylesheets
'bundles/admin/css/custom.css'
filter='cssrewrite,?yui_css'
 %}
<link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %}

我用

app/console cache:clear
app/console assets:install ../public_html --symlink   
app/console assetic:dump

--

问题

在 domain.tld 上一切正常,但问题出在子域上。

来自 admin.domain.tld 的源代码

<link rel="stylesheet" href="/css/8d488cd_custom_11.css"/>

8d488cd_custom_11.css

div.image {
    background-image: url(../../bundles/admin/images/image.png);
}

从萤火虫

"NetworkError: 404 Not Found - http://admin.domain.tld/bundles/admin/images/image.png"

知道如何将代码或配置更正为(css背景)也适用于子域和根域吗?

4

0 回答 0