Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New websites are pointing to 1st VirtualHost

Status
Not open for further replies.

force5

ISP
Nov 4, 2004
118
US
When adding a new customer's website to the webserver and Network Solutions does not have it officially pointing to the webserver's IP yet, I notice that Apache points the web browser to the first VirtualHost in my httpd.conf file?
Why is that....can I (or should I) change that?
 
Globally? Wait for NS to get finished setting up DNS.

Locally? Add an entry to your machine's hosts file which maps the URL to the IP address.


Keep in mind how Apache matches a browser request to a virtual web server when multiple virtual web servers share an IP address....

The browser connects to an IP address on port 80 and sends an HTTP string which contains:

GET / HTTP/1.1
Host:
(as well as other HTTP headers). Apache then takes the FQDN referenced in the "Host:" line and tries to match it to the ServerName or ServerAlias entry for a virtual server which is configured to listen on that IP address and port. If Apache finds a match, it sends the appropriate data. If Apache cannot find a match, it sends data from the first site configured to listen on that address.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
That makes sence...but is there any way to stop that from pointing to the first website in my httpd.conf?
For example:
1 of our customers have 2 totally seperate websites, and They just added the 2nd site today. When I type in my browser it takes me to I have everything set correctly in the VirtualHost container. Can I stop this from pointing to the other site?
 
I'm guessing that we're talking about named virtual hosts (as opposed to IP based virtual hosts). The most common cause of the behavior that you're seeing is incorrect apache configuration. When apache is not set correctly or can not determine which virtual host is being requested, it will server the first virtual host.

See: faq65-1831 How to set up Name Based Vitualhosts on Apache.
and
(If you are using IP based virtual hosts, the same concepts still apply, the configuration is just different).
 
When you refer to your "1st website", are you referring to the Default Server?

The Apache documentation states that ALL websites should be created as virtual servers, and the Default Server should be understood to be a fallback in case there are any resolution issues (such as what you have cited).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top