I've problems setting up a virtual host on windows7, so that I can develop multiple pages on my localhost. To set up the virtual Host, I've edited 3 Files:

  • httpd-vhosts.conf in apache\conf\extra
  • httpd.conf in apache\conf
  • hosts in system32\drivers\etc

This is what I've done in order to make the page run on Port 81:

added this block in httpd-vhosts.conf

NameVirtualHost *:81
<VirtualHost *:81>
    DocumentRoot C:\xampp\htdocs\mypage
    ServerName mypage
    DirectoryIndex index.html index.php
    <Directory "C:\xampp\htdocs\mypage">
        Options Indexes FollowSymLinks Includes ExecCGI
        Order allow,deny
        Allow from all
        AllowOverride All

made apache Listen on Port 81 in httpd.conf

Listen 80
Listen 81

added this line in hosts    mypage

But as soon as I try to access mypage via localhost:81, I get redirected to localhost/xampp.

  • In httpd.conf is it properly loading httpd-vhosts.conf? Or is that line commented out?
    – Anagio
    Commented Dec 24, 2012 at 17:18
  • Why are you making Apache2 listen on port 81? You don't have to use a different port for a virtual host.
    – Anagio
    Commented Dec 24, 2012 at 17:20
  • The Line is not commented out. I used a different port because I did it exactly the same way on an other pc and it worked Commented Dec 24, 2012 at 23:17
  • Do you have mod_rewrite active? If so, enable RewriteLog and see what it's doing. Otherwise, monitor the HTTP traffic and check Apache's main logs. See how you're being redirected to the different hostname. Commented Dec 25, 2012 at 14:24

1 Answer 1


You must

  • Read Apache docs
  • Understand Apache docs
  • Select better-suited module for virtual-hosts for your needs (from at least two)
  • Enable selected module in LoadModule
  • Restart Apache after editing configs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.