(06-14-2023, 09:05 PM)kenjis Wrote: (06-13-2023, 11:25 PM)sstefanov Wrote: And I want to have these kinds of URLs:
website.com/fr/blog
website.com/fr/services
website.com/fr/contacts
website.com/fr
website.com/blog
website.com/services
website.com/contacts
website.com
Notice that there is no website.com/en/something. The reason is that this is a requirement for SEO to be good enough for Google.
Is the following something wrong for SEO?
website.com/en/blog
website.com/en/services
website.com/en/contacts
website.com/en
website.com/fr/blog
website.com/fr/services
website.com/fr/contacts
website.com/fr
Yes.
This is how your meta tags should look like for my example case:
<meta content="en" http-equiv="content-language">
<link rel="alternate" hreflang="x-default" href="https://website.com/">
<link rel="alternate" hreflang="en" href="https://website.com/">
<link rel="alternate" hreflang="fr" href="https://website.com/fr">
As you may have seen from meta tags, the default behaviour is to have the "en" version without the "en" at the end of your url.
If you have website.com/en - this is duplicate content for search engines. And you should be having some content on website.com (without any language at the end), right?
I can't wrap my head around why the CodeIgniter's team didn't think of this basic case. I've seen tens of people complaining about this issue everywhere, and they just ignore them.
It takes literally no more than a few lines of code to implement this in their core engine.
PHP Code:
foreach(['', '{locale}'] as $prefix) {
$routes->group($prefix, static function ($routes) {
$routes->get('blog', 'Blog::index');
// e.tc.
})
}
})
}
Actually I like this solution very much, thank you iRedds