IP in Host Header from Client

Discussion in 'Apache' started by TennisGuy, Aug 14, 2007.

  1. #1
    I have a subdomain with it's own IP and it's own Apache instance but the user's browser is going to myDomain.com/default.jsp instead of subdomain.myDomain.com/default.jsp when the IP is entered as the URL (http://1.2.3.4). There is only one VirtualHost declared in the httpd.conf file.

    As a side note, when I do a reverse lookup on the IP of the subdomain, it does not resolve to the subdomain. So I'm not sure if I have a DNS issue and not an apache issue.

    Thanks in advance.
     
    TennisGuy, Aug 14, 2007 IP
  2. TennisGuy

    TennisGuy Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Okay, I've figured out that it's finding it's way to the defined VirtualHost because it's going to the appServer asking for the correct page. For example,
    DirectoryIndex mySubdomain/default.jsp.
    I now realize it's not maintaining the subdomain in the URL because it's not coming in with the subdomain in the Host header.

    So how can I have them routed by one VirtualHost declaration if they come in with just the IP and another if they have a host name declared? For example:

    <VirtualHost>
    Use this one if browser sends Host: 1.2.3.4
    </VirtualHost>

    <VirtualHost>
    Use this one if browser sends Host: mysubdomain.mydomain.com
    </VirtualHost>
     
    TennisGuy, Aug 14, 2007 IP