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 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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程