Routing {locale} : Duplicate Content [SOLVED in next release] |
Hi all,
When we use the "{locale}" tag in a route, it can generate Duplicate Content, even when using the $supportedLocales variable For example if I use : PHP Code: public $supportedLocales = ['en', 'fr']; When I go to a url of type - mywebsite.com/en/page.html = code 200 ("en" version) - mywebsite.com/en/page.html = code 200 ("fr" version or "en" version if "fr" does not exist) - mywebsite.com/lorem/page.html = code 200 ("en" version) - mywebsite.com/codeignitertest/page.html = code 200 ("en" version) etc. Do we have to check in our Controller that the language exists? And if yes, how to get the information from the $supportedLocales variable? Otherwise, wouldn't it be interesting in the next version, to put an option to avoid this duplicate content For example, if {locale} does not correspond to any language present in $supportedLocales, then, we return a 404 error Regards Ps : The variable "$supportedLocales" is defined as "@var string[]" What is the difference with "@var array"? (it's just for my personal culture ) --- I am not a developer ---
(06-29-2022, 10:09 AM)InstantT Wrote: Do we have to check in our Controller that the language exists? Yes, you need to check now. And v4.3 will have the option. See https://github.com/codeigniter4/CodeIgniter4/pull/6073 (06-29-2022, 10:09 AM)InstantT Wrote: Ps : The variable "$supportedLocales" is defined as "@var string[]" string[] means array of string items. Controller[] means array of Controller objects.
string[] means that the array contains only strings as values. ['a', 'b', 'text', ]
array - means that it is an array with any content. ['a', 1, new stdClass, null, false] This gives an idea of what the array contains, and in the case of the IDE, you can get hints. |
Welcome Guest, Not a member yet? Register Sign In |