Is here any possibility to tell Symfony2 framework
that if all parameters in my route have default values will be redirected to this same route but withtout them? Same as Symfony2
generate URL adressses.
For example:
default_blog:
path: /{type}/{page}
defaults: { _controller: AcmeBlogBundle:Default:index, type: "page", page: 1}
requirements:
page: \d+
type: page
So if i have /page/2
it will be ok, but if I put /page/1
to URL I'll be redirected to /
. Is it possible and if is, how?
In action add parameter $page
which is a {page}
placeholder in route and then use if
for check first page. And same with type:
public function pageAction($type, $page) {
if ($type == 'page' && $page == 1) {
$this->redirect('/');
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.