Reputation: 279
I use symfony2 routing.yml for call main page:
web_homepage:
pattern: /
defaults: { _controller: SWebBundle:Default:index }
In this page i call Require, Backbone, use PushState, all ok, but, if one user go to, for example:
example.com /categories/animals
And copy this url and access directly, Symfony2 return 404
I use too patterns '/config/...' and '/api/...' for a lot of calls, and login/login_check
Well, i would like if exist any parameter 'default' for all calls where not appear in the routing, or to exclude config and api, because we controller 404 from backbone.js.
thanks ^^
Upvotes: 1
Views: 546
Reputation: 1152
here is my solution for Symfony 2.3.2:
routing.xml
<routes>
<route id="MyBundle.Default.index" path="/app">
<default key="_controller">MyBundle:Default:index</default>
</route>
<route id="MyBundle.Default.index2" path="/app/{url}">
<default key="_controller">MyBundle:Default:index</default>
<requirement key="url">.+</requirement>
</route>
</routes>
Controller:
class DefaultController extends Controller
{
public function indexAction()
{
return $this->render('MyBundle:Default:index.html.twig');
}
}
Here the reason https://stackoverflow.com/a/7892022 why I use:
<requirement key="url">.+</requirement>
Upvotes: 1