Search code examples
phpsymfonynginxroutescontrollers

Symfony 3 merge under global domain


I have domains webpage.com, webpage.ee, webpage.eu and I would like to merge them under the same domain with webpage.com/ee or webpage.com/eu.

What is the best/easiest way to achive this? All the domains currently use the same codebase.

Do I have to change all the routes and links manually or is there a better way?


Solution

  • Simplest way:

    server {
        listen 80;
        server_name example.com
        location /en {
            add_header X-Lang en
        }
        ...
    }
    

    Then in Symfony you probably need a request listener to read the language header and set the locale or whatever you may be interested in.

    You could also use more advanced techniques like regular expressions to match the locations, and set the header.