Reputation: 263
Symfony version: 3.0
I have set multiple sub-domains for my project:
www.example.com
, en.example.com
and so on.
for one article page the url is:
www.example.com/article-1.html
en.example.com/article-1.html
if i add a sub-domain for the current domain:
article.www.example.com
, article.en.example.com
the article.www.example.com
is not good solution, i want to remove the www
sub domain is article.example.com, when user open the en.example.com, the article.en.example.com is working.
how to do it?
i don't want to make a route file for each language site.
Upvotes: 0
Views: 252
Reputation: 311
You can do it on the main routing file in /app/config
by adding an host
field at the same level as your path
field and default
field. The host field should contain the domain and subdomain you want, like in this example :
english_homepage:
path: /
host: article.example.com
default: { _controller: AcmeDemoBundle:Main:articles }
main_homepage:
path: /
host: www.example.com
default: { _controller: AcmeDemoBundle:Main:homepage }
You can also use placeholder, parameters, and other possibilities. With them, you should be able to create variable subdomains to fit your needs.
For more information, read this : How to Match a Route Based on the Host
Upvotes: 1