Hello ![]()
I’m trying to add a param to the URL on a certain condition. I have a url /books and based on the year when I visit, I eventually want a param added automatically to the URL.
Here’s my config:
'routes' => [
[
'pattern' => '(:any)',
'action' => function($slug) {
if (str_ends_with($slug,"books")) {
$yearNow = date("Y");
if (statusFair($yearNow) == "now") {
return go('books'."/fairyear:".$yearNow);
}
$this->next();
}
$this->next();
}
]
I get the right URL in the browser tab but then an error is displayed saying redirect isn’t working.
Looks like the redirect is going in loops. ![]()
In deed, I checked and $slug doesn’t appear to catch params I’m afraid and whether I’m on /books or /books/fairyear:2024 its value is the same: books.
I can’t really do that with htaccess though. If anyone has a clue, I’d appreciate a lot. Been stuck on this for a while. ![]()