1
votes

I have a few subdomains that I use in my project, and I would like to have the main marketing site accept www as well as a blank subdomain

http://www.example.com & http://example.com

How can I achieve this with symfony?

This is my current setup

_main:
    resource: routing.yml

incompass_sterilization:
    host:     spd.casechek-dev.com
    resource: "@IncompassSterilizationBundle/Resources/config/routes.yml"

incompass_printing:
    host:     labels.casechek-dev.com
    resource: "@IncompassPrintingBundle/Resources/config/routes.yml"

incompass_admin:
    host:     admin.casechek-dev.com
    resource: "@IncompassAdminBundle/Resources/config/routes.yml"

incompass_web:
    host:     www.casechek-dev.com
    resource: "@IncompassWebBundle/Resources/config/routes.yml"

I looked at the documentation here http://symfony.com/doc/current/components/routing/hostname_pattern.html but I can only see how to setup different subdomains that exist, I can't work out how to use an empty subdomain.

edit duplicating the routes does not work, I can't get multiple routes to use the same controller. Here are 2 examples that did not solve the issue

Using the same routes file

incompass_web:
    host:     www.casechek-dev.com
    resource: "@IncompassWebBundle/Resources/config/routes.yml"

incompass_web_two:
    host:     casechek-dev.com
    resource: "@IncompassWebBundle/Resources/config/routes.yml"

Using separate routes files

incompass_web:
    host:     www.casechek-dev.com
    resource: "@IncompassWebBundle/Resources/config/routes.yml"

incompass_web_two:
    host:     casechek-dev.com
    resource: "@IncompassWebBundle/Resources/config/routes_two.yml"

routes.yml

incompass_web_main:
    type: annotation
    prefix: /
    resource: Incompass\WebBundle\Controller\MainController

routes_two.yml

incompass_web_main_two:
    type: annotation
    prefix: /
    resource: Incompass\WebBundle\Controller\MainController
1
Couldn't you just duplicate the routes for the main domain?Jason Roman
that doesn't work, I've added the things I tried to the main questionmike

1 Answers

0
votes

The only way I could get this to work was to use different types of routing.

app/config/routing.yml

_main:
    resource: routing.yml

incompass_sterilization:
    host:     spd.casechek-dev.com
    resource: "@IncompassSterilizationBundle/Resources/config/routes.yml"

incompass_printing:
    host:     labels.casechek-dev.com
    resource: "@IncompassPrintingBundle/Resources/config/routes.yml"

incompass_admin:
    host:     admin.casechek-dev.com
    resource: "@IncompassAdminBundle/Resources/config/routes.yml"

incompass_web:
    host:     www.casechek-dev.com
    resource: "@IncompassWebBundle/Resources/config/routes.yml"

incompass_web_two:
    host:     casechek-dev.com
    resource: "@IncompassWebBundle/Resources/config/routes_two.yml"

IncompassWebBundle/Resources/config/routes.yml

incompass_web_main:
    type: annotation
    prefix: /
    resource: Incompass\WebBundle\Controller\MainController

IncompassWebBundle/Resources/config/routes_two.yml

incompass_web_main_two:
    path: /
    defaults: { _controller: IncompassWebBundle:Main:index }