My symfony app should get user's language from subdomain:
en.project.com - for english fr.project.com - for french
and so on... Special filter get 'GET' param 'lang' from current uri and save it in user attribute. How can I setup 开发者_开发知识库apache virtual host config for multiple subdomains?
<VirtualHost *:80>
ServerName blah.com
ServerAlias de.blah.com en.blah.com fr.blah.com
...
</VirtualHost>
Read more about server aliases: http://httpd.apache.org/docs/2.0/en/mod/core.html#serveralias
Your Symfony filter can simply parse the domain during the first request and set a session variable. This is untested but should work:
<?php class localeFilter extends sfFilter
{
  public function execute($filterChain)
  {
    // Execute this filter only once
    if ($this->isFirstCall()) {
      $host = $_REQUEST['HTTP_HOST'];
      $locale = array_shift(explode(".",$host));
      $this->getUser()->setAttribute('locale', $locale);
    }
    // Execute next filter
    $filterChain->execute();
  }
} ?>
You'll need simply to rewrite wildcard domain using mod_rewrite, and when you'll have subdomain as a parameter, you can go ahead.
http://www.easymodrewrite.com/example-subdomains
Try to add them as ServerAlias in your httpd config file.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论