ArVan
ArVan

Reputation: 4275

Symfony 2 on virtual hosts

I have a problem here with Symfony 2. I want to have virtual host on Windows Vista PC, so I can access my Symfony application like this myapp.local.com. What I have tried:

but when I write myapp.local.com in my browser, it brings the index of my www directory. What am I doing wrong?

Upvotes: 12

Views: 48284

Answers (2)

fudu
fudu

Reputation: 742

Windows version for symfony 3.4:
Just simple like this:

C:\xampp\apache\conf\extra\httpd-vhosts.conf

<VirtualHost *:80>
  DocumentRoot "C:/xampp/htdocs/symfony_CRUD/web"
  DirectoryIndex app_dev.php
  ServerName fudu.symfony.net
</VirtualHost>

C:\Windows\System32\drivers\etc

127.0.0.1 fudu.symfony.net

Then you go fudu.symfony.net/app_dev.php
Hope it help some one :)

Upvotes: 0

Nanocom
Nanocom

Reputation: 3726

You are using the virtualhost configuration proposed for Symfony 1.

My virtualhost for Symfony2 under linux looks like this:

<VirtualHost *:80>
    ServerName www.domain.com.localhost
    ServerAlias domain.com.localhost
    ServerAdmin webmaster@localhost

    DocumentRoot /home/user/www/project/web
    <Directory /home/user/www/project/web/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
        <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ /app.php [QSA,L]
        </IfModule>
    </Directory>
</VirtualHost>

Try this (adapted to your config in windows), restart Apache, and try accessing the URL again.

You will find more informations on Symfony2 virtual hosts on this cookbook entry.

Upvotes: 49

Related Questions