Search code examples
symfonynginxsymfony-routing

Symfony2 and Nginx, route by hostname


I have one Symfony2 project named SymfonyProject.

I had until now one nginx config file that points to that project with www.symfonyproject.com

I developed some static twig pages in the SymfonyProject which I would like to access with another url: www.symfonyproject2.com

So, the www.symfonyproject2.com will only access one route from the SymfonyProject.

How to do this with Nginx? I created another config file in sites enabled, but don't know how to redirect trafic to a specific symfony2 route.


Solution

  • Actually your nginx can use the www.symfonyproject2.com as alias and inside symfony you can use a route which is going to match by hostname: http://symfony.com/doc/current/components/routing/hostname_pattern.html

    This should be enough to solve your problem!

    Let me know if it helped you!