How to make global pages using a defragmented URI

I currently have a page like this

http://mypage.com/

I put all languages ​​on one page and languages ​​are judged by the user's language setting.

However, I've heard that this is not good for SEO.

I would like to use a defferent url like

http://mypage.com/fr

http://mypage.com/en

http://mypage.com/ja

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

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

      

I searched Google many times but couldn't find the manual document.

+3


source to share


1 answer


You can use the _locale routing component like this:

# app/config/routing.yml

acme_top_top:
    path:      /{_locale}
    defaults:  { _controller: AcmeTopBundle:Default:index, _locale: en }
    requirements:
        _locale:  en|fr

      



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

Hope for this help

+3


source







All Articles