Friday, November 2, 2007

Creating a Virtual Host in Apache (Windows)

1. Open file 'httpd-vhosts.conf' file
\apache\conf\extra\httpd-vhosts.conf

2. Uncomment/add the following line:
NameVirtualHost *:80

3. Add the following code:
<virtualhost *:80>
ServerName www.example.com
DocumentRoot "E:/XAMPP/htdocs/mysitefolder"
</virtualhost>


note: replace the path in red with your path

4. Configure 'hosts' file
\system32\drivers\etc\hosts

127.0.0.1 www.example.com

4. Restart xammp.

5. Try typing "www.example.com" in your browser!! :) ?

4 comments:

Malaya Kutissery said...

Use the following to check any syntax errors for httpd.conf

C:\Program Files\Apache Group\Apache2\bin>apache -t
Syntax OK

http://johnbokma.com/windows/apache-virtual-hosts-xp.html

anand said...

in lampp use the following syntax

sudo /opt/lampp/bin/apachectl -t

anand said...

After adding a virtual host, if it redirects to http://vhosts/xampp, make sure httpd-vhosts.conf is uncommented in httpd.conf

http://serverfault.com/questions/165421/unable-to-configure-custom-virtualhosts-in-xampp

anand said...

having a tld .local will point you to htdocs
https://stackoverflow.com/questions/48513297/apache-virtual-host-always-redirecting-to-dashboard

.dev gives https error