Andrew
Andrew

Reputation: 6394

VIrtualHost: Different hosts point to the same location

I am trying to set virtual hosts for two Zend Framework applications. I started by changing the system32 hosts file.

It contains the following lines now:

127.0.0.1           localhost
#   ::1             localhost
127.0.0.1           quickstart

After that, I proceeded with changing the httpd-vhosts.conf file. Its current content:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "G:\workspace\Andrew\ProjManer\public"
    ServerName localhost
    ServerAlias localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" combined
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "G:\workspace\Andrew\quickstart\public"
    ServerName quickstart
    ServerAlias quickstart
    ErrorLog "logs/quickstart-error.log"
    CustomLog "logs/quickstart-access.log" combined
</VirtualHost>

If I don't add the virtual host with localhost first, I get a "Access forbidden 403 Error message".
The problem now is that both point to the same location, the localhost. How am I supposed to get the second virtual host working? I used the flushdns also.

Upvotes: 0

Views: 1754

Answers (1)

Chris McKnight
Chris McKnight

Reputation: 8600

You don't need the ServerAlias in them unless you want say quickstart2 to go to quickstart. In that case you will do ServerAlias quickstart2. You get access forbidden because your document root in your httpd.conf doesn't have an index.php or that virtualhost doesn't have an index.php and you have -Indexes set

Other than that the virtualhost and hosts file look fine. Try restarting your browser and restarting apache.

Upvotes: 2

Related Questions