Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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
    </Directory>
</VirtualHost>

made apache Listen on Port 81 in httpd.conf

Listen 80
Listen 81

added this line in hosts

127.0.0.1    mypage

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

share|improve this question
    
In httpd.conf is it properly loading httpd-vhosts.conf? Or is that line commented out? –  Anagio Dec 24 '12 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 Dec 24 '12 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 –  Martin Sheen Dec 24 '12 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. –  Lèse majesté Dec 25 '12 at 14:24
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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