i have 3 domains pointed at my linux box, apache2 virtual hosts is set up so that each domain loads the appropriate webpage when you visit it outside of the LAN.

my trouble is trying to view the pages from the LAN.

if i go to the boxes lan ip, i get the contents of /var/www/html/

how would i go about viewing the 3 other domains that are located in /var/www/(site-name-here) through the lan?

  • 1
    apache2 virtual hosts is correctly set up obviously not :) Jun 3, 2016 at 18:22
  • ok ok i'll remove the word correctly. :)
    – helmet648
    Jun 3, 2016 at 19:14

1 Answer 1


Your attempting to access the site using a IP address when your virtual host file is setup to use a domain name, not an IP address... so it'll throw up the default folder, in this case /var/www/html/.

Fix 1. Local Virtual host file

The most common and easy method to fix the issue would be to edit your host file within Windows or Mac, this will allow you to access all sites locally, using the domain name as you would externally...

The host file would look something like this:

# Copyright (c) 1993-2009 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
# For example:
#     rhino.acme.com          # source server
# exampleA.com exampleB.com exampleC.com

Fix 2. Virtual IP addresses

Since you have 3 sites and if you intend to be able to visit all of these via the internal lan IP then are faced with a greater issue of how can you tell Apache2, which site to return when you only have one IP address...

The a fix would be to use virtual IP addresses, and assign a virtual IP address to the virtual host, rather than using *.

Something like this:

# Site A
    ServerName www.example-1.com
    DocumentRoot /var/www/exampleA

# Site A
    ServerName www.example-2.com
    DocumentRoot /var/www/exampleB

# Site C
    ServerName www.example-3.com
    DocumentRoot /var/www/exampleC

Using the above will allow you to visit the sites using the virtual IP addresses.

Fix 3. Map folders

You can map folders as alias so that when someone visits they get site A, or going to /exampleB will get site B etc.

Something like this:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    Alias /ExampleA /var/www/exampleA
    Alias /exampleB /var/www/exampleB

    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
  • didn't even think about setting my windows hosts file... thanks for all the useful info!
    – helmet648
    Jun 3, 2016 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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