Matanya
Matanya

Reputation: 6346

Virtual host on Apache 2 isn't working as excpected

I'm trying to set a development server on my OSX 10.8.2. The deployed site name is mattat.org.il so I'd like to set it to mattat.dev.

These are the steps I followed:

  1. Uncommented the include for virtual hosts, in httpd.conf:

    Include /private/etc/apache2/extra/httpd-vhosts.conf

  2. added a virtual host to httpd-hosts.conf:

    NameVirtualHost *:80
    <VirtualHost *:80>
    DocumentRoot "/Users/matanya/Sites/matat"
    ServerName mattat.dev
    </VirtualHost>`
    
  3. Added the server name to etc/hosts:

    127.0.0.1 localhost
    255.255.255.255 broadcasthost
    ::1             localhost.
    fe80::1%lo0 localhost
    127.0.0.1 mattat.dev
    
  4. Restarted Apache.

Now, when i go to localhost it takes me to the directory I've set for the virtual host, instead of taking me the the root directory (i.e Sites). When I go to mattat.dev it is unidentified as a valid url, and simply interpreted as a Google search.

What am I missing?

Upvotes: 1

Views: 472

Answers (1)

PassKit
PassKit

Reputation: 12581

.dev is not a valid TLD, your browser is not treating it as a URL. http://mattat.dev should work.

For not recognising localhost, check that you have a default directory in your httpd.conf for Apache to fall back on if it cannot find a virtual host, or alternatively add a second Virtual host for localhost.

<Directory "/Users/matanya/Sites/">
    Options Indexes
    Order allow,deny
    Allow from all
</Directory> 

Upvotes: 2

Related Questions