duanmuybrtg1231
duanmuybrtg1231
2015-07-21 09:52
浏览 64
已采纳

如何使用不同的URI使全局页面

Currently I have a page like this

http://mypage.com/

I put every languages in the same page and languages are judged by user locale setting.

However, I have heard its not good for SEO.

I would like to use defferent URL like

http://mypage.com/fr

http://mypage.com/en

http://mypage.com/ja

I have many questions. where should I judge the language?? How I redirect page to page ?? How do I write routing.yml??

acme_top_top:
    pattern:  /fr
    defaults: { _controller: AcmeTopBundle:Default:index }
acme_top_top:
    pattern:  /en
    defaults: { _controller: AcmeTopBundle:Default:index }

I have googled many times but cant find the guideline document.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongyuxin5353
    dongyuxin5353 2015-07-21 10:31
    已采纳

    You can using the _locale of the Routing component as follow:

    # app/config/routing.yml
    
    acme_top_top:
        path:      /{_locale}
        defaults:  { _controller: AcmeTopBundle:Default:index, _locale: en }
        requirements:
            _locale:  en|fr
    

    You can define a default locale also. More info on the doc page.

    Hope this help

    点赞 评论

相关推荐