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

Optional section in URL #7

Open
bossqone opened this issue Aug 17, 2013 · 1 comment
Open

Optional section in URL #7

bossqone opened this issue Aug 17, 2013 · 1 comment
Labels

Comments

@bossqone
Copy link

Hello, how can I make "lang" section optional, please ?

There is regexp - "/\w{2}:lang/pages/:title"

Thanks for quick answer.
(Sorry for my bad english).

@deceze
Copy link
Owner

deceze commented Aug 18, 2013

You can't really make a part optional at this point, you'd have to define two separate routes for this:

$r->add('/\w{2}:lang/pages/:title', ...);
$r->add('/pages/:title', ...);

If you have to do this a lot, you could automate the creation of these routes:

foreach ($myRoutes as $route) {
    $r->add('/\w{2}:lang' . $route['route'], ...);
    $r->add($route['route'], ...);
}

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

No branches or pull requests

2 participants