How to create the route in symfony 2 which maps to external URL?
You can do this by using one of the Symfony framework controllers although I'm not sure how this would work with parameters:
blog_show: path: /blog/{slug} defaults: _controller: FrameworkBundle:Redirect:urlRedirect path: "http://example.com/blog" permanent: true
Note that path: /blog/{slug}
grabs the slug directly, but path: "http://example.com/blog/{slug}"
doesn't work.
Source: http://symfony.com/doc/current/cookbook/routing/redirect_in_config.html
As of Symfony 2.2 this is possible by adding the host constraint to the routes:
routing.yml
user_homepage: path: /path/to/whatever host: "sub.domain.ext" defaults: _controller: forExampleAnyNamespaceBundle:Controller:action
There's an official blog post on this issue: http://symfony.com/blog/new-in-symfony-2-2-url-host-support-in-the-routing
The router feature of Symfony doesn't work that way...
I suggest you create a Twig extension for this. Read more about this here:http://symfony.com/doc/current/cookbook/templating/twig_extension.html
You could create a function that works very similar to the regular url() function, so you can migrate as easily as possible.
{{ legacyUrl('blog_post', {slug: 'my-blog-post'}) }}
After you migrated the blog to Symfony, all you need to do is create a route called "blog_post" and change "legacyUrl" to "url".