Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have following configuration file on my Debian machine:

<VirtualHost *:80>
    ServerAdmin me@domain.tld

    VirtualDocumentRoot /var/workspace/www/%2_%3/%1

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>

    <Directory /var/workspace/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Which is great for automation - i just create a directory in specific path and domain just start working.

But sometimes I need to launch apps, which has docroots somewhere else (typicaly www dir or something else), how do I specify this VirtualHosts and keep working the old automatic VirtualHosts?

When I add e.g. this:

<VirtualHost *:80>
  ServerName www.phabricator.com.local
  DocumentRoot /var/workspace/www/phabricator_com/www/webroot

  RewriteEngine on
  RewriteRule ^/rsrc/(.*)     -                       [L,QSA]
  RewriteRule ^/favicon.ico   -                       [L,QSA]
  RewriteRule ^(.*)$          /index.php?__path__=$1  [L,QSA]

  SetEnv PHABRICATOR_ENV custom/socialbakers
</VirtualHost>

It routes all requests on /var/workspace/www/phabricator_com/www/webroot and ignores the other vhosts (mentioned above).

Why?

share|improve this question

2 Answers 2

Be sure to have enabled the directive to allow named virtual hosts. I mean:

NameVirtualHost *:80

... in your /etc/httpd/conf/httpd.conf file.

share|improve this answer
    
When I add specifically NameVirtualHost, it says: [warn] NameVirtualHost *:80 has no VirtualHosts . So if I change the basic VirtualHost from 127.0.0.1:80 to *:80, it still routes all requests to the first one (www.phabricator.com.local). –  Radek Simko Mar 5 '12 at 20:46

Are you sure you have provided the proper name after ServerName? I mean, it ends with .local; is it what the HTTP request Host header contains? If there Host header in the HTTP request doesn't match any of the name-based vhosts (or if the request has no Host header), the first vhost will be used.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.