1

I have following configuration file on my Debian machine:

<VirtualHost *:80>
    ServerAdmin [email protected]

    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?

2 Answers 2

1

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

NameVirtualHost *:80

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

1
  • 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). Mar 5, 2012 at 20:46
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .