Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to create a virtual host for PHP developement, so I don't go to http://localhost/new_website, but to and get the website.

I've created the directory in the /Sites folder and edited the /etc/apache2/extra/httpd-vhosts.conf file and the /private/etc/hosts file.

The content of my vhosts file:

# Virtual Hosts
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
# Please see the documentation at 
# <URL:>
# for further details before you try to setup virtual hosts.
# You may use the command line option '-S' to verify your virtual host
# configuration.

# Use name-based virtual hosting.
NameVirtualHost *:80

# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.

<VirtualHost *:80>
    DocumentRoot "/Users/Rob/Sites"
    ServerName localhost

<VirtualHost *:80>
    DocumentRoot "/Users/Rob/Sites/new_website"

And the content of my hosts file:

# Host Database
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##   localhost broadcasthost
::1             localhost 
fe80::1%lo0 localhost

And from what I found on the internet, this should to the trick, but somehow, I don't get the index.php from the new_website directory, but I get the index.php from the Sites directory. So the root of the server so to say. What am I doing wrong?

share|improve this question

You must log in to answer this question.

Browse other questions tagged .