Reputation: 391
My question is: How can I generate external url from routing.yml?
I want something similar to:
documentation_product1:
pattern: /my/documentation/product1.php
default: http://www.myothersite.com/product1
Is it possible or something similar?
Upvotes: 2
Views: 2361
Reputation: 1098
It is possible to redirect within a controller to an external site
documentation_product1:
pattern: /my/documentation/product1.php
defaults: { _controller: AcmeBundle:Product:show }
// in controller
$this->redirect('http://www.myothersite.com/product1');
But it is not a good practise.
It is better to use the RedirectController from the FrameworkBundle.(mantioned by Paulpro)
Doku:
http://symfony.com/doc/current/cookbook/routing/redirect_in_config.html
Upvotes: 6
Reputation: 4715
Symfony routes the requested url to a pair of controller and action to execute. It does only internal redirects.
For a redirect to an external URL you need .htaccess and mod_rewrite (if you use apache).
Upvotes: -1