0

I have two subdomains pointing to the "web" directory in my Symfony 1.4 implementation and would like to route to certain modules/actions based which subdomain was used to arrive at the site

sub1.domain.com --> module1/action
sub2.domain.com --> module2/action

Is there an easy way to do this in routing.yml? Customize index.php, parsing the host for subdomain?

James
  • 4,117
  • 2
  • 18
  • 13

2 Answers2

3

Take a look at this chapter in More With Symfony. It does essentially the same thing by creating a custom route that checks the subdomain... It uses the DB but you could omit that if you dont need to hit the DB.

prodigitalson
  • 60,050
  • 10
  • 100
  • 114
  • Thanks. Not the simple yml config a Symfony newb was hoping for, but looks like it's the right approach – James Jan 10 '11 at 06:43
  • Its actually not that complex, i swear. :-) Just FYI if you wanted to switch apps as opposed to module/action youd want to look at filters or modifying the index.php... or additional .htaccess rules... which one of those three to choose would really depend on the situation. – prodigitalson Jan 10 '11 at 06:50
  • I have a better understanding of your recommendations now, thanks. Could you please review this related question? http://stackoverflow.com/questions/4702414/how-to-structure-this-symfony-web-project – James Jan 16 '11 at 02:15
2

I'd rather write an execution filter or custom routing class.

Check out this example: http://www.symfony-project.org/more-with-symfony/1_4/en/02-Advanced-Routing

Jakub Zalas
  • 35,761
  • 9
  • 93
  • 125