Closed wizhippo closed 7 years ago
Hi mister wizhippo,
I'm not sure that will be a hood answer for your issue, but i will try
If we have a site with multi-language, same domain for each language (example.com) and one suffix for each language
In my Apache configuration, i will define first afeter "RewriteEngine On" something like that
RewriteCond %{REQUEST_URI} !^/(_wdt|_fos_user_context_hash|sitemap\.xml|robots\.txt)
RewriteCond %{REQUEST_URI} !^/(favicon.*\.png|apple-touch-icon.*\.png|mstile.*\.png|browserconfig\.xml|favicon\.ico)
RewriteCond %{REQUEST_URI} !^/(fr|en|extension|var|design|packages|share|api)(/|).*
RewriteRule ^(.*) /en$1 [R=301,L]
if page is loaded without prefixing siteaccess language suffix, you will be redirect on the english siteaccess
so you will never have access to http://example.com/foo/bar you will be redirect on http://example.com/en/foo/bar
That prevents duplicate content without defining alternate and canonical metas for this specific case (domain without lang suffix that normally call the default siteaccess).
I will document how to set SITEBUILDER Environment variable in Apache, this will look like that
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{REQUEST_URI} ^/en(/.*|)$
RewriteRule .* - [E=SITEBUILDER_ENV:Acme_Foo_Bar,NE]
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{REQUEST_URI} ^/fr(/.*|)$
RewriteRule .* - [E=SITEBUILDER_ENV:Acme_Foo_Bar,NE]
AppKernel wiil look this SITEBUILDER Environment variable to load specific BarBundle for the Customer Foo when loading http://example.com/fr. and/or http://example.com/en/
I too had thought of just redirecting. I have had a client that wanted the same content on both and use the canonical metas. I too prefer the redirect.
When using the same domain and url to identify site access the ability to alias the main language to the root directory would be useful.
for example when creating the site you could add an option in the language list to alias to the root so in the end you could have:
example.com -> eng-GB example.com/en -> eng-GB example.com/fr -> fr-FR