I was trying to make a Symfony 2 page when accessed through a browser (ex. example.com) it will redirect to the index page of a bundle.
There shouldn't be a example.com/web or anything at all, how can I achieve this?
You can redirect()
to generate an HTTP redirect.
return $this->redirect($this->generateUrl('bundle_index')); // 302 Moved
Or you render immediately without a redirect using forward()
, so the URL wouldn't change.
return $this->forward($this->generateUrl('bundle_index'));
The other option is to explicitly connect the home page path, to a controller.
# routing.yml
_default:
resource: "@YourDefaultBundle/Controller/"
type: annotation
prefix: /