Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm installing a symfony project on /var/www/

And I have a special landing page stored here /var/www/web/landingpage

I want my visitors accessing to land on my landingpage and the ones accessing to land on my symfony project.

I created 2 virtualhosts with different ServerPath and the landing page is working but not the symfony project.

Here is my conf:

<VirtualHost *:80>
    ServerPath /
    DocumentRoot /var/www/web/landingpage
    ErrorLog ${APACHE_LOG_DIR}/

<VirtualHost *:80>
    ServerPath /sf/

    DocumentRoot /var/www/web

    DirectoryIndex frontend.php

    <Directory /var/www/web>
            Order allow,deny
            Allow from all
            AllowOverride none

            <IfModule mod_rewrite.c>
                    RewriteEngine On

                    # we check if the .html version is here (caching)
                    RewriteRule ^$ index.html [QSA]
                    RewriteRule ^([^.]+)$ $1.html [QSA]
                    RewriteCond %{REQUEST_FILENAME} !-f

                    # no, so we redirect to our front web controller
                    RewriteRule ^(.*)$ frontend.php [QSA,L]

    Alias /sf /var/www/lib/vendor/symfony/data/web/sf

    ErrorLog ${APACHE_LOG_DIR}/mydomain.sf.error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/mydomain.sf.access.log combined

Note: my second Virtualhost without the first one and without ServerPath directive is working perfectly

share|improve this question
With name based hosting, you should have only one virtual host entry for this hostname. Then you can handle it several ways. One solution would be to use an index page that forwards to the desired location. You could also accomplish with htaccess or mod_rewrite. But to start with, don't try to have 2 virtualhosts for the same hostname - combine into 1 and work from there. Or change your symphony project to use a subdomain such as –  user16081-JoeT Feb 1 '13 at 19:08
I wish I could do this. But for marketing reasons (bags have been printed with, I can't... And I can't change my symfony project as easy as I wish because 2 other languages (.fr and .de are working well like this :/) –  MaximeBernard Feb 2 '13 at 14:29

1 Answer 1

You cannot have two virtual host entries with the same hostname. That simply does not work.

Here's what you can do:

Change the second virtualhost to have


Leave everything else as it is in that second virtualhost.

In your first virtualhost, you add the following lines:

RewriteEngine On
RewriteRule ^/foo$ [L,R]

Then, when anybody accesses they will be redirected to, the second virtualhost.

share|improve this answer

Your Answer


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.