skip to Main Content

I’ve configured Apache on a web server so that different domains show different websites.

While I wait for the DNS updates that will point my domain at this servers IP address, I’d like to test if my website is running correctly.

Is there a way I can access a website via it’s IP address, but do something in the client so as to tell the Apache server I’ve accessed it via a domain I specify?

2

Answers


  1. Sure: just add a Host field with the DNS name to your HTTP header/

    At the TCP/IP level, a DNS resolver translates a hostname into an IP address, permitting the client to connect to the server.

    But, once the TCP/IP connection is established, the HTTP headers provide additional information to the web server. In particular, the "Host" header field provides the host and port number of the server to which the request is being sent. Apache reads this information to redirect to a virtual host.

    I hope that helps!

    Login or Signup to reply.
  2. It treats the config files in a top-down approach. It will default to the first vhost based upon alpahbet (if no numbers are present), or the lowest number config file.

    For example:

    000-default.conf
    test.com.conf
    site-a.com.conf
    site-b.com.conf
    

    In the above, 000-default will be the default, because it goes “numbers, then letters”.

    To see which one is being used:

    apache2ctl -S
    

    So you can basically rename and check.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search