Reputation: 13
I want to do a route for home page, so if it is / or /index or /index.php send to same controller(to Index controller)
So i wrote this
homepage:
pattern: /
defaults: { _controller: DprocMainBundle:Index:index}
homepage_1:
pattern: /index
defaults: { _controller: DprocMainBundle:Index:index}
homepage_2:
pattern: /index.php
defaults: { _controller: DprocMainBundle:Index:index}
It works, but its duplicate.. How i can do multiple route at once?
Upvotes: 1
Views: 2314
Reputation: 41954
You can use optional parts in your routing:
homepage:
pattern: /{name}.{ext}
defaults:
_controller: ...
name: index
ext: php
requirements:
ext: php
name: index
SIDEBAR: In the future, there will be better support for optional placeholders: https://github.com/symfony/symfony/issues/5424
Upvotes: 1