Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lang prefix in urls #248

Open
thierryler opened this issue Mar 7, 2020 · 1 comment
Open

lang prefix in urls #248

thierryler opened this issue Mar 7, 2020 · 1 comment

Comments

@thierryler
Copy link

Hello,

My website uses urls that can include the language as prefix.

For example:
website.com/en/article/abcd123
website.com/fr/article/abcd123

Or also (especially for google reasons):
website.com/en-us/article/abcd123
website.com/en-uk/article/abcd123

But this prefix is optional. The default lang is set to 'fr' if missing.
For example:
website.com/article/abcd123

Actually, all those example urls should go to the same controller, asking the "article" with id "abcd123". The only difference is the lang.

My question is about the "lang" parameter here. What do you recommend to handle that?

PS : I have many languages on my website (fr, en, it, sp, etc.) and many routes (article, pay, profil, etc.). I do not want to double each route for each lang.

@MrPropre
Copy link

$router->map('GET', '/[*:lang]?/article/[a:id]');

lang parameter is optional here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants