• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Apache virtual hosting

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
I have an Apache 2.0 running on localhost.
My default DocumentRoot is set to:
DocumentRoot "H:/apache2.0/Apache2/htdocs"

I'm trying to use virtual hosting (for testing), and I've got the following settings:
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1>
DocumentRoot "c:/mywebpage"
ServerName localhost
</VirtualHost>
Now when I type "http://localhost" in my browser, apache still serves the index page from the default DocumentRoot !
Why's this ?

Thanks everyone
Dennis
 
Saloon Keeper
Posts: 28141
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because you have a conflict between the virtual host and the default host - you're giving them both the same URL!
A more realistic setup would be to do:
<VirtualHost 127.0.0.1:8080>
in order to see the alternate (virtual) host as http://localhost:8080.
This requires that you tell Apache it's OK to serve out of port 8080 in addition to port 80.
The other use of VirtualHost is to access under a different domain, like so:
<VirtualHost www.mydomain.com>
<VirtualHost info.mydomain.com>
<VirtualHost www.otherdomain.net>
Which provides 4 total host URLs - the default +
http://www.mydomain.com, http://info.mydomain.com, and http://www.otherdomain.net.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cool .. thanks a lot !
 
A magnificient life is loaded with tough challenges. En garde tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic