TYPO3 v9.5 Sites: Language Redirects

北慕城南 提交于 2020-04-30 16:32:32

问题


I am using TYPO3 v9.5 LTS.

The following languages are defined:
0 = en
1 = de

Site Config General:
[base] = /

Site Config Language 0 (EN):
[base] = /en/

Site Config Language 1 (DE):
[base] = /de/

Now when you access the domain without any URL segment for the language, the user gets always redirected to the default language (en) instead if the proper browser language of the user (de).

Am I missing any configuration parameter in order to get a proper language redirect?
Or do I need make any configuration in TypoScript?

Thanks in advance :)


回答1:


Redirection by user language does not exist in TYPO3 itself, you will need to implement this yourself.

Here is a basic example for an Apache .htaccess:

RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP:Accept-Language} ^(de|en)
RewriteRule ^ https://%{HTTP_HOST}/%1/ [R=301,L,QSA]

This redirects all basic URLs depending on the browser language. So https://example.org/ will be redirected either to https://example.org/de/ or https://example.org/en/ or kept unchanged if a different language than German or English is preferred. URLs which already have a path (and thus a language segment) won't be redirected as are URLs which have a query string, thus things like https://example.org/?eID=... are not redirected.



来源:https://stackoverflow.com/questions/53445594/typo3-v9-5-sites-language-redirects

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!