0
<VirtualHost *:80>  
    DocumentRoot "C:/Program Files (x86)/Ampps/www"
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>  
    DocumentRoot "C:/Program Files (x86)/Ampps/www/proj"
    ServerName proj.local
</VirtualHost>

How do I bind a specific "domain" (virtual host domain) to one location? Above points proj.local to localhost as well.

John Svensson
  • 461
  • 1
  • 5
  • 17
  • see http://stackoverflow.com/questions/31380981/setting-up-virtual-hosts-in-ampps/31381045#31381045 – Nassim Jul 16 '15 at 20:38

3 Answers3

1

As you said you are using AMPPS, I suppose you are adding this instructions to the folder:

AMPPS/apache/conf/extra/httpd-vhosts.conf

With that in mind I'll show an example of configuration.

<VirtualHost project.local:80>
    <Directory "/Users/you/yourproject">
        Options FollowSymLinks Indexes
        AllowOverride All
        Order deny,allow
        allow from All
    </Directory>
    ServerName project.local
    ServerAlias project.local 127.0.0.1
    ScriptAlias /cgi-bin/ "/Users/you/yourproject/cgi-bin/"
    DocumentRoot "/Users/you/yourproject"
    ErrorLog "/Applications/AMPPS/apache/logs/project.error_log"
    CustomLog "/Applications/AMPPS/apache/logs/project.access.log" combined
</VirtualHost>

All right. After doing that, you will have to add to your hosts file. In Mac they are located in:

/etc/hosts

If you are using a Windows environment you will find the hosts file in:

c:\windows\system32\drivers\etc\hosts

Attention: You may have to type your password again or allow the program you're using to edit the file to use administrator privileges.

Then you'll add your local IP and the hostname to it. Just like this:

127.0.0.1      project.local

If you don't add the URL to the hosts file that won't work.

Daniel M. Melo
  • 118
  • 1
  • 6
0

Have you tried with <VirtualHOst proj.local:80>? You should be able to find more examples here: http://httpd.apache.org/docs/2.2/vhosts/examples.html

dkasipovic
  • 5,930
  • 1
  • 19
  • 25
0
<VirtualHost 127.0.0.1:80>
DocumentRoot "C:\xampp\htdocs"
ServerName xampp.local
ServerAlias www.xampp.local
</VirtualHost>

after adding it at the end of your httpd-vhosts.conf file restart your xampp and also add following lines to your hosts file available at C:\Windows\System32\Drivers\etc\hosts

127.0.0.1      xampp.local
Naveed Yousaf
  • 133
  • 2
  • 13
  • Anybody know the OSX equivalent to C:\Windows\System32\Drivers\etc\hosts - Windows or /etc/hosts - Linux (Ubuntu) ? – Huntario Aug 27 '14 at 01:43
  • Could not find it in the finder (hidden?). Had to use terminal $ sudo nano /private/etc/hosts – Huntario Aug 27 '14 at 01:49