schmittjoh / JMSI18nRoutingBundle

Allows you to internationalize your routing
http://jmsyst.com/bundles/JMSI18nRoutingBundle
358 stars 159 forks source link

Configuration with hosts, with/without "www." strategy #184

Closed picks44 closed 8 years ago

picks44 commented 8 years ago

Hello,

My question is in the subject. Here is my config.yml

# Jmsi18nRouting Configuration
jms_i18n_routing:
    default_locale: en
    locales: [en, de_DE, fr_FR]
    strategy: custom
    hosts:
        en: website.com
        de_DE: website.de
        fr_FR: website.fr
    redirect_to_host: true

If I put a Apache rule like this in my VHost, I have a "ERR_TOO_MANY_REDIRECTS" errors.

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^website\.com$ [NC]
    RewriteRule ^/(.*)$ http://www.website.com/$1 [R=301,L]

Please advise/help me, so our users can use both website.com and www.website.com to access our website !

picks44 commented 8 years ago

I've also tried with the following config, but this leads to a "ParameterNotFoundException in ParameterBag.php line 94: You have requested a non-existent parameter "website.com"." error.

# Jmsi18nRouting Configuration
jms_i18n_routing:
    default_locale: en
    locales: [en, de_DE, fr_FR]
    strategy: custom
    hosts:
        en: %website.com%
        de_DE: %website.de%
        fr_FR: %website.fr%
    redirect_to_host: true
picks44 commented 8 years ago

OK, solved this on my own. Kept the Apache config, and changed my config.yml like the following.

# Jmsi18nRouting Configuration
jms_i18n_routing:
    default_locale: en
    locales: [en, de_DE, fr_FR]
    strategy: custom
    hosts:
        en: www.website.com
        de_DE: www.website.de
        fr_FR: www.website.fr
    redirect_to_host: true