Force default language in url

Hi. I recently started to play with Grav in order to know whether it suitable for my next project.

And I have one question. Is there a way to force default language in url?
For example, I have 2 languages: ru and en. Ru is the default. I want for any given url without a language part to redirect to */ru/**. I know that currently it is available only for home page, using a home_redirect setting.
Currently I ended up with the following setting in system.yaml:
— yaml
home:
aliases:
ru: ‘/home’

languages:
home_redirect:
include_lang: true
include_route: false
supported:
- ru
- en


This results in the correct work of routes */ru/*, */ru/{anything}*. And */* correctly redirects to */ru/*. But routes */ru/{anything}* and */{anything}* produces the the same page, which is not very good for seo. I want */{anything}* to redirect to */ru/{anything}*. Or at least to answer 404 when someone requests */{anything}*. Is it possible in Grav? Or it can be done only using web server rewrite?

home_redirect.include_lang: true should do the trick http://learn.getgrav.org/content/multi-language#language-based-homepage

Nope. That will redirect only if I request the root resource i.e. /. If I request e.g. /blah it would be processed as is without including the language code

Currently you need to do it with a rewrite. There is an issue on the tracker, that is asking for the other way, i.e. anything that is /ru/{anything] be directed to /{anything} as that is the default language.

It’s something I plan on getting to, but as it can be done with rewrites pretty easily, i’m focusing on admin things at the moment.

Ok. Thanks for the answer. I’ll keep in mind that this feature will be implemented in the near future. :slight_smile: