我的symfony网站是代理通行证的背后,这是我的代理通行证:
<VirtualHost *:80>
ServerName mydomain.dev
ProxyPreserveHost on
# setup the proxy
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass /foo http://10.0.3.22/foo
ProxyPassReverse /foo http://10.0.3.22/foo
</VirtualHost>
因为mydomain.dev是另一个网站。
当我打开http://mydomain.dev/foo时,我的symfony网站呈现但所有资产都返回404 Not Found,因为它尝试从网址http://mydomain.dev/css/获取...而不是http://mydomain.dev/foo/css/ ...
如果我从proxypass中删除/ foo,也会遇到同样的问题:
ProxyPass /foo http://10.0.3.22/
ProxyPassReverse /foo http://10.0.3.22/
我希望我的symfony中的所有资产,所有路由和所有链接都以/ foo为前缀,是否有任何配置? Symfony或Apache配置?
由于
-
Symfony 2.5.6 | Apache 2.4
答案 0 :(得分:0)
自答案:
我在参数中添加了前缀:
#parameters.yml
parameters:
website_prefix: foo
并为我的所有路线添加了前缀,如下所示:
#app/config/routing_base.yml
twig:
globals:
asset_base: "/%website_prefix%"
login:
path: /login
defaults: { _controller:
ezpublish.security.controller:loginAction }
login_check:
path: /login_check
logout:
path: /logout
_ezpublishRoutes:
resource: "@EzPublishCoreBundle/Resources/config/routing/internal.yml"
_ezpublishLegacyRoutes:
resource: "@EzPublishLegacyBundle/Resources/config/routing.yml"
_ezpublishRestRoutes:
resource: "@EzPublishRestBundle/Resources/config/routing.yml"
prefix: %ezpublish_rest.path_prefix%
_ezpublishRestOptionsRoutes:
resource: "@EzPublishRestBundle/Resources/config/routing.yml"
prefix: %ezpublish_rest.path_prefix%
type: rest_options
_liip_imagine:
resource: "@LiipImagineBundle/Resources/config/routing.xml"
#_ezpublishDemoRoutes:
# resource: "@eZDemoBundle/Resources/config/routing.yml"
和
#app/config/routing.yml
_routing_prefixed:
resource: "routing_base.yml"
prefix: %website_prefix%
对于我的资产,我使用了一个树枝全局变量:
#app/config/config.yml
twig:
globals:
assets_base: "%website_prefix%"
在我的树枝上
{% stylesheets filter='?yui_css, cssrewrite' output='css/main.css'
'bundles/mybundle/css/bootstrap.css'
'bundles/mybundle/css/cs-select.css'
'bundles/mybundle/css/cs-skin-border.css'
'bundles/mybundle/css/video-js.css'
'bundles/mybundle/css/owl.carousel.css'
'bundles/mybundle/css/owl.theme.css'
'bundles/mybundle/css/main.css'
'bundles/mybundle/css/custom.css'
%}
<link href="{{ assets_base }}/{{ asset_url }}" rel="stylesheet">
{% endstylesheets %}
它运作良好:)