symfony 2 - 语言版本 - 找不到“GET /”的路由

时间:2018-04-03 14:12:34

标签: php symfony routing multilingual symfony-routing

Symfony2返回找不到" GET / nl"当我尝试运行http://localhost/nl

应用/配置/ routing.yml中

    #hwi_oauth_redirect:
    #    resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
    #    prefix:   /connect
    # 
    #hwi_oauth_login:
    #    resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
    #    prefix:   /login

    softlogo_works:
        resource: "@SoftlogoWorksBundle/Resources/config/routing.yml"
        prefix:   /{_locale}/
        requirements:
            _locale: en|pl|ru|fr|nl


    #softlogo_news:
        #resource: "@SoftlogoNewsBundle/Resources/config/routing.yml"
        #prefix:   /

    sonata:
        resource: "@SoftlogoCMSBundle/Resources/config/routing/sonata.yml"
        prefix:   /

        #host:     "{host}"
        #requirements:
            #host: "[a-zA-Z1-9\.\-]+"
        #defaults: {host: "ngmina.localhost"}


    gallery:
        resource: '@SonataMediaBundle/Resources/config/routing/gallery.xml'
        prefix: /media/gallery
    media:
        resource: '@SonataMediaBundle/Resources/config/routing/media.xml'
        prefix: /media

    news:
        resource: '@SonataNewsBundle/Resources/config/routing/news.xml'
        prefix: /{_locale}/news
        requirements:
            _locale: en|pl|ru|fr|nl

    softlogo_portfolio:
        resource: "@SoftlogoPortfolioBundle/Resources/config/routing.yml"
        prefix:   /{_locale}/projekty
        requirements:
            _locale: en|pl|ru|fr|nl

    softlogo_product:
        resource: "@SoftlogoProductBundle/Resources/config/routing.yml"
        prefix:   /product
        requirements:
            _locale: en|pl|ru|fr|nl
    softlogo_shop:
        resource: "@SoftlogoShopBundle/Resources/config/routing.yml"
        prefix:   /shop
        requirements:
            _locale: en|pl|ru|fr|nl
    #softlogo_portfolio:
    #softlogo_portfolio:
    #    resource: "@SoftlogoPortfolioBundle/Resources/config/routing.yml"
    #    prefix:   /portfolio
    #
    softlogo_cms:
        resource: "@SoftlogoCMSBundle/Resources/config/routing.yml"
        prefix:   /
    simple_things_entity_audit:
        resource: "@SimpleThingsEntityAuditBundle/Resources/config/routing.yml"
        prefix: /audit

应用/配置/ routing_dev.yml:

_wdt:
    resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
    prefix:   /_wdt

_profiler:
    resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
    prefix:   /_profiler

_configurator:
    resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
    prefix:   /_configurator

_errors:
    resource: "@TwigBundle/Resources/config/routing/errors.xml"
    prefix:   /_error

_main:
    resource: routing.yml

错误页面

Error Page

该网站包含5种语言版本,但问题仅发生在nl版本中,其他所有版本都正常工作。 我已经清理了缓存文件夹,但没有效果。

可能是什么问题?

2 个答案:

答案 0 :(得分:0)

您应该在app/config/config.yml

中启用区域设置
parameters:
    locale: en

framework:
    #esi: ~
    translator: { fallbacks: ['%locale%'] }

答案 1 :(得分:0)

您在前缀

的末尾添加了额外的'/'
softlogo_works:
    resource: "@SoftlogoWorksBundle/Resources/config/routing.yml"
    prefix:   /{_locale}
    requirements:
        _locale: en|pl|ru|fr|nl