John Svensson
John Svensson

Reputation: 461

Add Virtual Host for Localhost Ampps

<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.

Upvotes: 0

Views: 10110

Answers (3)

Daniel M. Melo
Daniel M. Melo

Reputation: 118

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.

Upvotes: 1

Naveed Yousaf
Naveed Yousaf

Reputation: 133

<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

Upvotes: 0

dkasipovic
dkasipovic

Reputation: 6120

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

Upvotes: 0

Related Questions